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 diff --git a/docs/core/proto-docs.md b/docs/core/proto-docs.md index a01f8940c0..e9718495d8 100644 --- a/docs/core/proto-docs.md +++ b/docs/core/proto-docs.md @@ -856,6 +856,34 @@ - [Msg](#lbm.foundation.v1.Msg) +- [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) + +- [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 +12711,289 @@ Msg defines the foundation Msg service. + +
+ +## 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 | + + + + + + + + + + + + + + + + + + +## 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) | | | + + + + + + + + + + + + + + + + + + +## lbm/fswap/v1/params.proto + + + + + +### Params +Params defines the parameters for the module. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `new_coin_denom` | [string](#string) | | new denomination for new coin after swap | + + + + + + + + + + + + + + + + + + +## lbm/fswap/v1/genesis.proto + + + + + +### GenesisState +GenesisState defines the fswap module's genesis state. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `params` | [Params](#lbm.fswap.v1.Params) | | | +| `swapped` | [Swapped](#lbm.fswap.v1.Swapped) | | | + + + + + + + + + + + + + + + + + + +## lbm/fswap/v1/query.proto + + + + + +### QuerySwappedRequest + + + + + + + + + +### QuerySwappedResponse + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `swapped` | [Swapped](#lbm.fswap.v1.Swapped) | | | + + + + + + + + +### 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| + + + + + + + + +## lbm/fswap/v1/tx.proto + + + + + +### MsgSwapAllRequest + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `from_address` | [string](#string) | | holder's address | + + + + + + + + +### MsgSwapAllResponse + + + + + + + + + +### 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) | | | + + + + + 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/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/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 new file mode 100644 index 0000000000..ae0a9ade75 --- /dev/null +++ b/proto/lbm/fswap/v1/genesis.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 "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 new file mode 100644 index 0000000000..da236c9373 --- /dev/null +++ b/proto/lbm/fswap/v1/params.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; +package lbm.fswap.v1; + +option go_package = "github.com/Finschia/finschia-sdk/x/fswap/types"; + +import "gogoproto/gogo.proto"; + +// Params defines the parameters for the module. +message Params { + option (gogoproto.goproto_stringer) = false; + // new denomination for new coin after swap + string new_coin_denom = 1; +} diff --git a/proto/lbm/fswap/v1/query.proto b/proto/lbm/fswap/v1/query.proto new file mode 100644 index 0000000000..f5d92c7bfc --- /dev/null +++ b/proto/lbm/fswap/v1/query.proto @@ -0,0 +1,29 @@ +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"; +import "lbm/fswap/v1/fswap.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 { + Swapped swapped = 1 [(gogoproto.nullable) = false]; +} + +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..c9b3c171bc --- /dev/null +++ b/proto/lbm/fswap/v1/tx.proto @@ -0,0 +1,29 @@ +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 {} 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| diff --git a/x/fswap/client/cli/query.go b/x/fswap/client/cli/query.go new file mode 100644 index 0000000000..55ec1d2bd1 --- /dev/null +++ b/x/fswap/client/cli/query.go @@ -0,0 +1,79 @@ +package cli + +import ( + "fmt" + + "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" +) + +// 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( + 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 new file mode 100644 index 0000000000..9b2f915ab7 --- /dev/null +++ b/x/fswap/client/cli/tx.go @@ -0,0 +1,95 @@ +package cli + +import ( + "fmt" + "time" + + "github.com/spf13/cobra" + + "github.com/Finschia/finschia-sdk/client" + "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()) + +// 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, + } + cmd.AddCommand( + CmdTxMsgSwap(), + CmdTxMsgSwapAll(), + ) + + return cmd +} + +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/genesis.go b/x/fswap/genesis.go new file mode 100644 index 0000000000..af232aad36 --- /dev/null +++ b/x/fswap/genesis.go @@ -0,0 +1,24 @@ +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" +) + +// 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..43bc7afc7c --- /dev/null +++ b/x/fswap/genesis_test.go @@ -0,0 +1 @@ +package fswap_test diff --git a/x/fswap/handler.go b/x/fswap/handler.go new file mode 100644 index 0000000000..2e3dae3f45 --- /dev/null +++ b/x/fswap/handler.go @@ -0,0 +1,26 @@ +package fswap + +import ( + "fmt" + + 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 ... +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..b55b7c1155 --- /dev/null +++ b/x/fswap/keeper/grpc_query.go @@ -0,0 +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_test.go b/x/fswap/keeper/grpc_query_params_test.go new file mode 100644 index 0000000000..9429264902 --- /dev/null +++ b/x/fswap/keeper/grpc_query_params_test.go @@ -0,0 +1 @@ +package keeper_test diff --git a/x/fswap/keeper/keeper.go b/x/fswap/keeper/keeper.go new file mode 100644 index 0000000000..329b87cf80 --- /dev/null +++ b/x/fswap/keeper/keeper.go @@ -0,0 +1,39 @@ +package keeper + +import ( + "fmt" + + "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" +) + +type ( + Keeper struct { + cdc codec.BinaryCodec + accountKeeper types.AccountKeeper + bankKeeper types.BankKeeper + storeKey storetypes.StoreKey + } +) + +func NewKeeper( + cdc codec.BinaryCodec, + ak types.AccountKeeper, + bk types.BankKeeper, + storeKey storetypes.StoreKey, +) Keeper { + return Keeper{ + cdc: cdc, + accountKeeper: ak, + bankKeeper: bk, + storeKey: storeKey, + } +} + +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..41b76b832a --- /dev/null +++ b/x/fswap/keeper/msg_server.go @@ -0,0 +1,29 @@ +package keeper + +import ( + "context" + + "github.com/Finschia/finschia-sdk/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{} + +// 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") +} diff --git a/x/fswap/keeper/msg_server_test.go b/x/fswap/keeper/msg_server_test.go new file mode 100644 index 0000000000..9429264902 --- /dev/null +++ b/x/fswap/keeper/msg_server_test.go @@ -0,0 +1 @@ +package keeper_test diff --git a/x/fswap/keeper/params.go b/x/fswap/keeper/params.go new file mode 100644 index 0000000000..5a539d551a --- /dev/null +++ b/x/fswap/keeper/params.go @@ -0,0 +1,16 @@ +package keeper + +import ( + sdk "github.com/Finschia/finschia-sdk/types" + "github.com/Finschia/finschia-sdk/x/fswap/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..9429264902 --- /dev/null +++ b/x/fswap/keeper/params_test.go @@ -0,0 +1 @@ +package keeper_test diff --git a/x/fswap/keeper/query_params_test.go b/x/fswap/keeper/query_params_test.go new file mode 100644 index 0000000000..9429264902 --- /dev/null +++ b/x/fswap/keeper/query_params_test.go @@ -0,0 +1 @@ +package keeper_test diff --git a/x/fswap/module.go b/x/fswap/module.go new file mode 100644 index 0000000000..0e60e1d03d --- /dev/null +++ b/x/fswap/module.go @@ -0,0 +1,168 @@ +package fswap + +import ( + "encoding/json" + "fmt" + + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + abci "github.com/tendermint/tendermint/abci/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 ( + _ 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() +} + +// 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 1 } + +// 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..48b26e84a0 --- /dev/null +++ b/x/fswap/module_simulation.go @@ -0,0 +1 @@ +package fswap diff --git a/x/fswap/simulation/simap.go b/x/fswap/simulation/simap.go new file mode 100644 index 0000000000..1b74bcd04c --- /dev/null +++ b/x/fswap/simulation/simap.go @@ -0,0 +1,15 @@ +package simulation + +import ( + sdk "github.com/Finschia/finschia-sdk/types" + simtypes "github.com/Finschia/finschia-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..72003233c5 --- /dev/null +++ b/x/fswap/types/codec.go @@ -0,0 +1,23 @@ +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" +) + +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..c0b627de88 --- /dev/null +++ b/x/fswap/types/errors.go @@ -0,0 +1,12 @@ +package types + +// DONTCOVER + +import ( + sdkerrors "github.com/Finschia/finschia-sdk/types/errors" +) + +// x/fswap module sentinel errors +var ( + ErrSample = sdkerrors.Register(ModuleName, 1100, "sample error") +) 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/expected_keepers.go b/x/fswap/types/expected_keepers.go new file mode 100644 index 0000000000..6134a117d7 --- /dev/null +++ b/x/fswap/types/expected_keepers.go @@ -0,0 +1,18 @@ +package types + +import ( + 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) +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/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.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..af2475beea --- /dev/null +++ b/x/fswap/types/genesis.pb.go @@ -0,0 +1,376 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: lbm/fswap/v1/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"` + Swapped Swapped `protobuf:"bytes,2,opt,name=swapped,proto3" json:"swapped"` +} + +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_94e309cb1db27661, []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 (m *GenesisState) GetSwapped() Swapped { + if m != nil { + return m.Swapped + } + return Swapped{} +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "lbm.fswap.v1.GenesisState") +} + +func init() { proto.RegisterFile("lbm/fswap/v1/genesis.proto", fileDescriptor_94e309cb1db27661) } + +var fileDescriptor_94e309cb1db27661 = []byte{ + // 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, 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) { + 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.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 { + 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)) + l = m.Swapped.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 + 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:]) + 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..e4fa429dc8 --- /dev/null +++ b/x/fswap/types/genesis_test.go @@ -0,0 +1,41 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/Finschia/finschia-sdk/x/fswap/types" +) + +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/msgs.go b/x/fswap/types/msgs.go new file mode 100644 index 0000000000..4f4ad81cb5 --- /dev/null +++ b/x/fswap/types/msgs.go @@ -0,0 +1,70 @@ +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} +} + +// 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 +} + +// 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()} +} + +// 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 +} + +// GetSigners Implements Msg. +func (msg MsgSwapAllRequest) GetSigners() []sdk.AccAddress { + from, err := sdk.AccAddressFromBech32(msg.FromAddress) + if err != nil { + panic(err) + } + return []sdk.AccAddress{from} +} diff --git a/x/fswap/types/params.go b/x/fswap/types/params.go new file mode 100644 index 0000000000..f4b9ae24dc --- /dev/null +++ b/x/fswap/types/params.go @@ -0,0 +1,26 @@ +package types + +import ( + "gopkg.in/yaml.v2" +) + +// NewParams creates a new Params instance +func NewParams() Params { + return Params{} +} + +// DefaultParams returns a default set of parameters +func DefaultParams() Params { + return NewParams() +} + +// 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..fd779ed5a6 --- /dev/null +++ b/x/fswap/types/params.pb.go @@ -0,0 +1,319 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: lbm/fswap/v1/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 { + // new denomination for new coin after swap + NewCoinDenom string `protobuf:"bytes,1,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_15e620b81032c44d, []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 (m *Params) GetNewCoinDenom() string { + if m != nil { + return m.NewCoinDenom + } + return "" +} + +func init() { + proto.RegisterType((*Params)(nil), "lbm.fswap.v1.Params") +} + +func init() { proto.RegisterFile("lbm/fswap/v1/params.proto", fileDescriptor_15e620b81032c44d) } + +var fileDescriptor_15e620b81032c44d = []byte{ + // 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) { + 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 + 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] = 0xa + } + 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 + l = len(m.NewCoinDenom) + if l > 0 { + n += 1 + l + sovParams(uint64(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 { + case 1: + 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:]) + 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..b3635cf9ad --- /dev/null +++ b/x/fswap/types/query.pb.go @@ -0,0 +1,868 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: lbm/fswap/v1/query.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" + _ "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 + +type QuerySwappedRequest struct { +} + +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 *QuerySwappedRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QuerySwappedRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QuerySwappedRequest.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 *QuerySwappedRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySwappedRequest.Merge(m, src) +} +func (m *QuerySwappedRequest) XXX_Size() int { + return m.Size() +} +func (m *QuerySwappedRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySwappedRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QuerySwappedRequest proto.InternalMessageInfo + +type QuerySwappedResponse struct { + Swapped Swapped `protobuf:"bytes,1,opt,name=swapped,proto3" json:"swapped"` +} + +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 *QuerySwappedResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QuerySwappedResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QuerySwappedResponse.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 *QuerySwappedResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySwappedResponse.Merge(m, src) +} +func (m *QuerySwappedResponse) XXX_Size() int { + return m.Size() +} +func (m *QuerySwappedResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySwappedResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QuerySwappedResponse proto.InternalMessageInfo + +func (m *QuerySwappedResponse) GetSwapped() Swapped { + if m != nil { + return m.Swapped + } + return Swapped{} +} + +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((*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{ + // 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. +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 { + 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 { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +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 + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + 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) 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_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).Swapped(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/lbm.fswap.v1.Query/Swapped", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + 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: "lbm.fswap.v1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Swapped", + Handler: _Query_Swapped_Handler, + }, + { + MethodName: "TotalNewCurrencySwapLimit", + Handler: _Query_TotalNewCurrencySwapLimit_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + 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.Swapped.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 *QueryTotalSwappableAmountRequest) 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 *QueryTotalSwappableAmountRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryTotalSwappableAmountRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryTotalSwappableAmountResponse) 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 *QueryTotalSwappableAmountResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryTotalSwappableAmountResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.SwappableNewCoinAmount.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 *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.Swapped.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryTotalSwappableAmountRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + 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 +} + +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 *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 Swapped", 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.Swapped.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 { + 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: QueryTotalSwappableAmountRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryTotalSwappableAmountRequest: 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 *QueryTotalSwappableAmountResponse) 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: QueryTotalSwappableAmountResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + 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 SwappableNewCoinAmount", 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.SwappableNewCoinAmount.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..5a63817f6a --- /dev/null +++ b/x/fswap/types/query.pb.gw.go @@ -0,0 +1,210 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: lbm/fswap/v1/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/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 + +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.Swapped(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +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.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 + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + 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() + 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_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_TotalNewCurrencySwapLimit_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_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) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + 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_TotalNewCurrencySwapLimit_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + 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_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 new file mode 100644 index 0000000000..682ec7260b --- /dev/null +++ b/x/fswap/types/tx.pb.go @@ -0,0 +1,913 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// 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. +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 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 "" +} + +type MsgSwapAllResponse struct { +} + +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 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{ + // 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. +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 { + 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 { + cc grpc1.ClientConn +} + +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: "lbm.fswap.v1.Msg", + HandlerType: (*MsgServer)(nil), + 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 + 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 + 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 { + 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") +) 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