forked from cerc-io/laconicd-deprecated
lint
This commit is contained in:
@@ -50,7 +50,7 @@ func NewCreateBondCmd() *cobra.Command {
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddTxFlags(cmd)
|
||||
cmd, _ = flags.AddTxFlags(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
@@ -75,8 +75,8 @@ func RefillBondCmd() *cobra.Command {
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg)
|
||||
},
|
||||
}
|
||||
flags.AddTxFlags(cmd)
|
||||
|
||||
cmd, _ = flags.AddTxFlags(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
@@ -101,12 +101,12 @@ func WithdrawBondCmd() *cobra.Command {
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg)
|
||||
},
|
||||
}
|
||||
flags.AddTxFlags(cmd)
|
||||
|
||||
cmd, _ = flags.AddTxFlags(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// CancelBondCmd is the CLI command for cancelling a bond.
|
||||
// CancelBondCmd is the CLI command for canceling a bond.
|
||||
func CancelBondCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "cancel [bond Id]",
|
||||
@@ -122,6 +122,7 @@ func CancelBondCmd() *cobra.Command {
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg)
|
||||
},
|
||||
}
|
||||
flags.AddTxFlags(cmd)
|
||||
|
||||
cmd, _ = flags.AddTxFlags(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
@@ -242,7 +242,7 @@ func (s *IntegrationTestSuite) TestTxCancelBond() {
|
||||
testCases := []struct {
|
||||
name string
|
||||
args []string
|
||||
getBondId bool
|
||||
getBondID bool
|
||||
err bool
|
||||
}{
|
||||
{
|
||||
@@ -275,7 +275,7 @@ func (s *IntegrationTestSuite) TestTxCancelBond() {
|
||||
s.Run(fmt.Sprintf("Case %s", tc.name), func() {
|
||||
clientCtx := val.ClientCtx
|
||||
cmd := cli.CancelBondCmd()
|
||||
if tc.getBondId {
|
||||
if tc.getBondID {
|
||||
cmd := cli.GetQueryBondLists()
|
||||
|
||||
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{
|
||||
|
||||
+7
-13
@@ -119,10 +119,7 @@ func (k Keeper) CreateBond(ctx sdk.Context, ownerAddress sdk.AccAddress, coins s
|
||||
Sequence: account.GetSequence(),
|
||||
}.Generate()
|
||||
|
||||
maxBondAmount, err := k.getMaxBondAmount(ctx)
|
||||
if err != nil {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Invalid max bond amount.")
|
||||
}
|
||||
maxBondAmount := k.getMaxBondAmount(ctx)
|
||||
|
||||
bond := types.Bond{Id: bondID, Owner: ownerAddress.String(), Balance: coins}
|
||||
if bond.Balance.IsAnyGT(maxBondAmount) {
|
||||
@@ -130,7 +127,7 @@ func (k Keeper) CreateBond(ctx sdk.Context, ownerAddress sdk.AccAddress, coins s
|
||||
}
|
||||
|
||||
// Move funds into the bond account module.
|
||||
err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, ownerAddress, types.ModuleName, bond.Balance)
|
||||
err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, ownerAddress, types.ModuleName, bond.Balance)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -198,7 +195,7 @@ func (k Keeper) ListBonds(ctx sdk.Context) []*types.Bond {
|
||||
func (k Keeper) QueryBondsByOwner(ctx sdk.Context, ownerAddress string) []types.Bond {
|
||||
var bonds []types.Bond
|
||||
|
||||
ownerPrefix := append(prefixOwnerToBondsIndex, []byte(ownerAddress)...)
|
||||
ownerPrefix := append(prefixOwnerToBondsIndex, []byte(ownerAddress)...) //nolint: all
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
itr := sdk.KVStorePrefixIterator(store, ownerPrefix)
|
||||
defer itr.Close()
|
||||
@@ -233,10 +230,7 @@ func (k Keeper) RefillBond(ctx sdk.Context, id string, ownerAddress sdk.AccAddre
|
||||
}
|
||||
}
|
||||
|
||||
maxBondAmount, err := k.getMaxBondAmount(ctx)
|
||||
if err != nil {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Invalid max bond amount.")
|
||||
}
|
||||
maxBondAmount := k.getMaxBondAmount(ctx)
|
||||
|
||||
updatedBalance := bond.Balance.Add(coins...)
|
||||
if updatedBalance.IsAnyGT(maxBondAmount) {
|
||||
@@ -244,7 +238,7 @@ func (k Keeper) RefillBond(ctx sdk.Context, id string, ownerAddress sdk.AccAddre
|
||||
}
|
||||
|
||||
// Move funds into the bond account module.
|
||||
err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, ownerAddress, types.ModuleName, coins)
|
||||
err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, ownerAddress, types.ModuleName, coins)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -314,10 +308,10 @@ func (k Keeper) CancelBond(ctx sdk.Context, id string, ownerAddress sdk.AccAddre
|
||||
return &bond, nil
|
||||
}
|
||||
|
||||
func (k Keeper) getMaxBondAmount(ctx sdk.Context) (sdk.Coins, error) {
|
||||
func (k Keeper) getMaxBondAmount(ctx sdk.Context) sdk.Coins {
|
||||
params := k.GetParams(ctx)
|
||||
maxBondAmount := params.MaxBondAmount
|
||||
return sdk.NewCoins(maxBondAmount), nil
|
||||
return sdk.NewCoins(maxBondAmount)
|
||||
}
|
||||
|
||||
// GetBondModuleBalances gets the bond module account(s) balances.
|
||||
|
||||
Reference in New Issue
Block a user