Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
harish551 committed Aug 14, 2024
1 parent b341f24 commit e84fe37
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
- '**.go'

env:
GO_VERSION: '1.21.3'
GO_VERSION: '1.22.5'

permissions:
contents: read
Expand Down
4 changes: 2 additions & 2 deletions x/streampay/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (k Keeper) StreamingPayment(goCtx context.Context,
req *types.QueryStreamPaymentRequest,
) (*types.QueryStreamPaymentResponse, error) {
if req == nil {
return nil, status.Errorf(codes.InvalidArgument, "empty request")
return nil, status.Error(codes.InvalidArgument, "empty request")
}

ctx := sdk.UnwrapSDKContext(goCtx)
Expand All @@ -86,7 +86,7 @@ func (k Keeper) Params(goCtx context.Context,
req *types.QueryParamsRequest,
) (*types.QueryParamsResponse, error) {
if req == nil {
return nil, status.Errorf(codes.InvalidArgument, "empty request")
return nil, status.Error(codes.InvalidArgument, "empty request")
}

ctx := sdk.UnwrapSDKContext(goCtx)
Expand Down
39 changes: 26 additions & 13 deletions x/streampay/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,15 @@ func (k Keeper) CreateStreamPayment(ctx sdk.Context,
if duration <= 0 {
return "", errorsmod.Wrapf(
types.ErrInvalidAmount,
fmt.Sprintf("duration %s is not valid, should be a possitive value", duration.String()),
"duration %s is not valid, should be a positive value",
duration.String(),
)
}
if amount.IsNil() || amount.IsNegative() || amount.IsZero() {
return "", errorsmod.Wrapf(
types.ErrInvalidAmount,
fmt.Sprintf("amount %s is not valid format", amount.String()),
"amount %s is not valid format",
amount.String(),
)
}
endTime := ctx.BlockTime().Add(duration)
Expand Down Expand Up @@ -125,13 +127,15 @@ func (k Keeper) StopStreamPayment(ctx sdk.Context, streamId string, sender sdk.A
if !ok {
return errorsmod.Wrapf(
sdkerrors.ErrNotFound,
fmt.Sprintf("no stream payment found with id %s", streamId),
"no stream payment found with id %s",
streamId,
)
}
if sender.String() != streamPayment.Sender {
return errorsmod.Wrapf(
sdkerrors.ErrUnauthorized,
fmt.Sprintf("address %s is not allowed to stop the stream payment", streamId),
"address %s is not allowed to stop the stream payment",
streamId,
)
}
if !streamPayment.Cancellable {
Expand All @@ -143,7 +147,8 @@ func (k Keeper) StopStreamPayment(ctx sdk.Context, streamId string, sender sdk.A
if ctx.BlockTime().Unix() > streamPayment.EndTime.Unix() {
return errorsmod.Wrapf(
sdkerrors.ErrUnauthorized,
fmt.Sprintf("ended stream payment cannot be canceled, stream payment %s", streamId),
"ended stream payment cannot be canceled, stream payment %s",
streamId,
)
}
streamedAmount := float64(0)
Expand Down Expand Up @@ -187,26 +192,30 @@ func (k Keeper) ClaimStreamedAmount(ctx sdk.Context, streamId string, claimer sd
if !ok {
return errorsmod.Wrapf(
sdkerrors.ErrNotFound,
fmt.Sprintf("no stream payment found with id %s", streamId),
"no stream payment found with id %s",
streamId,
)
}
claimerAddr := claimer.String()
if claimerAddr != streamPayment.Recipient {
return errorsmod.Wrapf(
sdkerrors.ErrUnauthorized,
fmt.Sprintf("address %s is not allowed to claim the stream payment", claimerAddr),
"address %s is not allowed to claim the stream payment",
claimerAddr,
)
}
if ctx.BlockTime().Unix() < streamPayment.StartTime.Unix() {
return errorsmod.Wrapf(
types.ErrInvalidAmount,
fmt.Sprintf("stream payment %s is not started yet", streamId),
"stream payment %s is not started yet",
streamId,
)
}
if streamPayment.StreamedAmount.IsGTE(streamPayment.TotalAmount) {
return errorsmod.Wrapf(
types.ErrInvalidAmount,
fmt.Sprintf("stream payment %s is already fully claimed", streamId),
"stream payment %s is already fully claimed",
streamId,
)
}
switch streamPayment.GetStreamType() {
Expand All @@ -226,7 +235,8 @@ func (k Keeper) ClaimStreamedAmount(ctx sdk.Context, streamId string, claimer sd
default:
return errorsmod.Wrapf(
types.ErrInvalidStreamPaymentType,
fmt.Sprintf("stream payment %s has invalid type", streamId),
"stream payment %s has invalid type",
streamId,
)
}
return nil
Expand All @@ -236,7 +246,8 @@ func (k Keeper) claimDelayedStreamPayment(ctx sdk.Context, streamPayment types.S
if ctx.BlockTime().Unix() < streamPayment.EndTime.Unix() {
return errorsmod.Wrapf(
types.ErrInvalidAmount,
fmt.Sprintf("stream payment %s is delayed type and not ended yet", streamPayment.Id),
"stream payment %s is delayed type and not ended yet",
streamPayment.Id,
)
}
if err := k.TransferAmountFromModuleAccount(ctx, claimer, sdk.NewCoins(streamPayment.TotalAmount)); err != nil {
Expand All @@ -260,7 +271,8 @@ func (k Keeper) claimContinuousStreamPayment(ctx sdk.Context, streamPayment type
if amount.IsZero() || amount.IsNil() {
return errorsmod.Wrapf(
types.ErrInvalidAmount,
fmt.Sprintf("no valid amount to claim for stream payment %s ", streamPayment.Id),
"no valid amount to claim for stream payment %s ",
streamPayment.Id,
)
}
if err := k.TransferAmountFromModuleAccount(ctx, claimer, sdk.NewCoins(amount)); err != nil {
Expand Down Expand Up @@ -289,7 +301,8 @@ func (k Keeper) claimPeriodicStreamPayment(ctx sdk.Context, streamPayment types.
if amount.IsZero() || amount.IsNil() {
return errorsmod.Wrapf(
types.ErrInvalidAmount,
fmt.Sprintf("no valid amount to claim for stream payment %s ", streamPayment.Id),
"no valid amount to claim for stream payment %s ",
streamPayment.Id,
)
}
if err := k.TransferAmountFromModuleAccount(ctx, claimer, sdk.NewCoins(amount)); err != nil {
Expand Down

0 comments on commit e84fe37

Please sign in to comment.