Skip to content

Commit

Permalink
ignore typecast lints (#1740)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajansari95 authored Nov 13, 2024
1 parent fbfd536 commit eadd9a9
Show file tree
Hide file tree
Showing 17 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions x/airdrop/keeper/claim_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (k *Keeper) verifyDeposit(ctx sdk.Context, cr types.ClaimRecord, threshold
}

// calculate target amount
tAmount := threshold.MulInt64(int64(cr.BaseValue)).TruncateInt()
tAmount := threshold.MulInt64(int64(cr.BaseValue)).TruncateInt() //nolint:gosec

if gdAmount.LT(tAmount) {
return fmt.Errorf("insufficient deposit amount, expects %v got %v", tAmount, gdAmount)
Expand Down Expand Up @@ -296,7 +296,7 @@ func (k *Keeper) verifyOsmosisLP(ctx sdk.Context, proofs []*cmtypes.Proof, cr ty
if err := k.verifyDeposit(ctx, cr, dThreshold); err != nil {
return fmt.Errorf("%w, must reach at least %s of %d", err, tier4, cr.BaseValue)
}
tAmount := dThreshold.MulInt64(int64(cr.BaseValue / 2)).TruncateInt()
tAmount := dThreshold.MulInt64(int64(cr.BaseValue / 2)).TruncateInt() //nolint:gosec

// check liquidity threshold
if uAmount.LT(tAmount) {
Expand Down
8 changes: 4 additions & 4 deletions x/airdrop/keeper/claim_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@ func (k *Keeper) GetClaimableAmountForAction(ctx sdk.Context, chainID, address s
// calculate action allocation:
// - zone drop action weight * claim record max allocation
// note: use int32(action)-1 as protobuf3 spec valid enum start at 1
amount := zd.Actions[int32(action)-1].MulInt64(int64(cr.MaxAllocation)).TruncateInt64()
amount := zd.Actions[int32(action)-1].MulInt64(int64(cr.MaxAllocation)).TruncateInt64() //nolint:gosec

// airdrop has not yet started to decay
if ctx.BlockTime().Before(zd.StartTime.Add(zd.Duration)) {
return uint64(amount), nil
return uint64(amount), nil //nolint:gosec
}

// airdrop has started to decay, calculate claimable portion
Expand All @@ -163,7 +163,7 @@ func (k *Keeper) GetClaimableAmountForAction(ctx sdk.Context, chainID, address s
claimablePercent := sdk.OneDec().Sub(decayPercent)
amount = claimablePercent.MulInt64(amount).TruncateInt64()

return uint64(amount), nil
return uint64(amount), nil //nolint:gosec
}

// GetClaimableAmountForUser returns the amount claimable for the given user
Expand All @@ -186,7 +186,7 @@ func (k *Keeper) GetClaimableAmountForUser(ctx sdk.Context, chainID, address str
// protobuf3 spec: valid enum start at 1
action := i + 1

claimableForAction, err := k.GetClaimableAmountForAction(ctx, cr.ChainId, cr.Address, types.Action(action))
claimableForAction, err := k.GetClaimableAmountForAction(ctx, cr.ChainId, cr.Address, types.Action(action)) //nolint:gosec
if err != nil {
return 0, err
}
Expand Down
2 changes: 1 addition & 1 deletion x/airdrop/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var _ types.MsgServer = msgServer{}
func (k msgServer) Claim(goCtx context.Context, msg *types.MsgClaim) (*types.MsgClaimResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)

action := types.Action(msg.Action)
action := types.Action(msg.Action) //nolint:gosec

amount, err := k.Keeper.Claim(ctx, msg.ChainId, action, msg.Address, msg.Proofs)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions x/airdrop/types/airdrop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func TestAction_InBounds(t *testing.T) {
},
{
"exceed upper",
types.Action(len(types.Action_name)),
types.Action(len(types.Action_name)), //nolint:gosec
false,
},
{
Expand All @@ -308,7 +308,7 @@ func TestAction_InBounds(t *testing.T) {
},
{
"in bounds upper",
types.Action(len(types.Action_name) - 1),
types.Action(len(types.Action_name) - 1), //nolint:gosec
true,
},
}
Expand Down
2 changes: 1 addition & 1 deletion x/claimsmanager/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var (
// GetGenericKeyClaim returns the key for storing a given claim.
func GetGenericKeyClaim(key []byte, chainID, address string, module ClaimType, srcChainID string) []byte {
typeBytes := make([]byte, 4)
binary.BigEndian.PutUint32(typeBytes, uint32(module))
binary.BigEndian.PutUint32(typeBytes, uint32(module)) //nolint:gosec
key = append(key, chainID...)
key = append(key, 0x00)
key = append(key, address...)
Expand Down
2 changes: 1 addition & 1 deletion x/interchainstaking/keeper/callbacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ func checkTMStateValidity(

trustedHeader := tmtypes.Header{
ChainID: chainID,
Height: int64(header.TrustedHeight.RevisionHeight),
Height: int64(header.TrustedHeight.RevisionHeight), //nolint:gosec
Time: consState.Timestamp,
NextValidatorsHash: consState.NextValidatorsHash,
}
Expand Down
4 changes: 2 additions & 2 deletions x/interchainstaking/keeper/callbacks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1840,7 +1840,7 @@ func TestDepositIntervalCallback(t *testing.T) {
err = fmt.Errorf("pagination total exceeds int range: %d", res.Pagination.Total)
}
suite.NoError(err)
suite.Equal(txQueryCount, int(res.Pagination.Total)-3)
suite.Equal(txQueryCount, int(res.Pagination.Total)-3) //nolint:gosec
}

func TestDepositIntervalCallbackWithExistingTxs(t *testing.T) {
Expand Down Expand Up @@ -1889,7 +1889,7 @@ func TestDepositIntervalCallbackWithExistingTxs(t *testing.T) {
err = fmt.Errorf("pagination total exceeds int range: %d", res.Pagination.Total)
}
suite.NoError(err)
suite.Equal(txQueryCount, int(res.Pagination.Total)-3)
suite.Equal(txQueryCount, int(res.Pagination.Total)-3) //nolint:gosec
}

func decodeBase64NoErr(str string) []byte {
Expand Down
4 changes: 2 additions & 2 deletions x/interchainstaking/keeper/delegation.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ func (k *Keeper) WithdrawDelegationRewardsForResponse(ctx sdk.Context, zone *typ
if len(msgs) > math.MaxUint32 {
return fmt.Errorf("number of messages exceeds uint32 range: %d", len(msgs))
}
if err = zone.IncrementWithdrawalWaitgroup(k.Logger(ctx), uint32(len(msgs)), "WithdrawDelegationRewardsForResponse"); err != nil {
if err = zone.IncrementWithdrawalWaitgroup(k.Logger(ctx), uint32(len(msgs)), "WithdrawDelegationRewardsForResponse"); err != nil { //nolint:gosec
return err
}
k.SetZone(ctx, zone)
Expand Down Expand Up @@ -358,7 +358,7 @@ func (k *Keeper) FlushOutstandingDelegations(ctx sdk.Context, zone *types.Zone,
if numMsgs > math.MaxUint32 {
return fmt.Errorf("number of messages exceeds uint32 range: %d", numMsgs)
}
if err = zone.IncrementWithdrawalWaitgroup(k.Logger(ctx), uint32(numMsgs), "sending flush messages"); err != nil {
if err = zone.IncrementWithdrawalWaitgroup(k.Logger(ctx), uint32(numMsgs), "sending flush messages"); err != nil { //nolint:gosec
return err
}

Expand Down
2 changes: 1 addition & 1 deletion x/interchainstaking/keeper/proposal_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ func (k *Keeper) HandleUpdateZoneProposal(ctx sdk.Context, p *types.UpdateZonePr
return err
}

period := int64(k.GetParam(ctx, types.KeyValidatorSetInterval))
period := int64(k.GetParam(ctx, types.KeyValidatorSetInterval)) //nolint:gosec
query := stakingtypes.QueryValidatorsRequest{}
err := k.EmitValSetQuery(ctx, zone.ConnectionId, zone.ChainId, query, sdkmath.NewInt(period))
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions x/interchainstaking/keeper/receipt.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func (k *Keeper) SendTokenIBC(ctx sdk.Context, senderAccAddress sdk.AccAddress,
RevisionNumber: 0,
RevisionHeight: 0,
},
TimeoutTimestamp: uint64(ctx.BlockTime().UnixNano() + 5*time.Minute.Nanoseconds()),
TimeoutTimestamp: uint64(ctx.BlockTime().UnixNano() + 5*time.Minute.Nanoseconds()), //nolint:gosec
Memo: "",
})
return err
Expand Down Expand Up @@ -298,7 +298,7 @@ func ProdSubmitTx(ctx sdk.Context, k *Keeper, msgs []sdk.Msg, account *types.ICA
chunkSize = ICAMsgChunkSize
}

timeoutTimestamp := uint64(ctx.BlockTime().Add(ICATimeout).UnixNano())
timeoutTimestamp := uint64(ctx.BlockTime().Add(ICATimeout).UnixNano()) //nolint:gosec

for {
// if no messages, no chunks!
Expand Down
2 changes: 1 addition & 1 deletion x/interchainstaking/keeper/redemptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func (k *Keeper) HandleQueuedUnbondings(ctx sdk.Context, zone *types.Zone, epoch
}
}

if err = zone.IncrementWithdrawalWaitgroup(k.Logger(ctx), uint32(len(msgs)), "trigger unbonding messages"); err != nil {
if err = zone.IncrementWithdrawalWaitgroup(k.Logger(ctx), uint32(len(msgs)), "trigger unbonding messages"); err != nil { //nolint:gosec
return err
}
k.SetZone(ctx, zone)
Expand Down
2 changes: 1 addition & 1 deletion x/interchainstaking/keeper/withdrawal_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func (k *Keeper) IterateZoneWithdrawalRecords(ctx sdk.Context, chainID string, f
// IterateZoneStatusWithdrawalRecords iterate through records for a given zone / delegator tuple.
func (k *Keeper) IterateZoneStatusWithdrawalRecords(ctx sdk.Context, chainID string, status int32, fn func(index int64, record types.WithdrawalRecord) (stop bool)) {
statusBytes := make([]byte, 8)
binary.BigEndian.PutUint64(statusBytes, uint64(status))
binary.BigEndian.PutUint64(statusBytes, uint64(status)) //nolint:gosec
key := append([]byte(chainID), statusBytes...)
k.IteratePrefixedWithdrawalRecords(ctx, key, fn)
}
Expand Down
4 changes: 2 additions & 2 deletions x/interchainstaking/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func GetRedelegationKey(chainID, source, destination string, epochNumber int64)

func GetWithdrawalKey(chainID string, status int32) []byte {
statusBytes := make([]byte, 8)
binary.BigEndian.PutUint64(statusBytes, uint64(status))
binary.BigEndian.PutUint64(statusBytes, uint64(status)) //nolint:gosec
key := KeyPrefixWithdrawalRecord
key = append(append(key, chainID...), statusBytes...)
return key
Expand All @@ -153,7 +153,7 @@ func GetWithdrawalKey(chainID string, status int32) []byte {
// unbonding records are keyed by chainId, validator and epoch, as they must be unique with regard to this triple.
func GetUnbondingKey(chainID, validator string, epochNumber int64) []byte {
epochBytes := make([]byte, 8)
binary.BigEndian.PutUint64(epochBytes, uint64(epochNumber))
binary.BigEndian.PutUint64(epochBytes, uint64(epochNumber)) //nolint:gosec
return append(append(KeyPrefixUnbondingRecord, chainID+validator...), epochBytes...)
}

Expand Down
2 changes: 1 addition & 1 deletion x/mint/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (k Keeper) GetLastReductionEpochNum(ctx sdk.Context) int64 {
// SetLastReductionEpochNum set last Reduction epoch number.
func (k Keeper) SetLastReductionEpochNum(ctx sdk.Context, epochNum int64) {
store := ctx.KVStore(k.storeKey)
store.Set(types.LastReductionEpochKey, sdk.Uint64ToBigEndian(uint64(epochNum)))
store.Set(types.LastReductionEpochKey, sdk.Uint64ToBigEndian(uint64(epochNum))) //nolint:gosec
}

// get the minter.
Expand Down
2 changes: 1 addition & 1 deletion x/participationrewards/keeper/callbacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ func SetEpochBlockCallback(ctx sdk.Context, k *Keeper, args []byte, query icqtyp
connectionData.LastEpoch = blockResponse.SdkBlock.Header.Height
}

heightInBytes := sdk.Uint64ToBigEndian(uint64(connectionData.LastEpoch))
heightInBytes := sdk.Uint64ToBigEndian(uint64(connectionData.LastEpoch)) //nolint:gosec
// trigger a client update at the epoch boundary
k.IcqKeeper.MakeRequest(
ctx,
Expand Down
2 changes: 1 addition & 1 deletion x/participationrewards/keeper/submodule_osmosis.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (*OsmosisModule) ValidateClaim(ctx sdk.Context, k *Keeper, msg *types.MsgSu
if err != nil {
return sdk.ZeroInt(), err
}
lock = osmolockup.NewPeriodLock(uint64(poolID), addr, addr.String(), time.Hour, time.Time{}, sdk.NewCoins(coin))
lock = osmolockup.NewPeriodLock(uint64(poolID), addr, addr.String(), time.Hour, time.Time{}, sdk.NewCoins(coin)) //nolint:gosec
} else {
lock = osmolockup.PeriodLock{}
err := k.cdc.Unmarshal(proof.Data, &lock)
Expand Down
4 changes: 2 additions & 2 deletions x/participationrewards/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ func GetProtocolDataKey(pdType ProtocolDataType, key []byte) []byte {
if pdType < 0 {
panic(fmt.Sprintf("protocol data type is negative: %d", pdType))
}
return append(sdk.Uint64ToBigEndian(uint64(pdType)), key...)
return append(sdk.Uint64ToBigEndian(uint64(pdType)), key...) //nolint:gosec
}

func GetPrefixProtocolDataKey(pdType ProtocolDataType) []byte {
if pdType < 0 {
panic(fmt.Sprintf("protocol data type is negative: %d", pdType))
}
return sdk.Uint64ToBigEndian(uint64(pdType))
return sdk.Uint64ToBigEndian(uint64(pdType)) //nolint:gosec
}

0 comments on commit eadd9a9

Please sign in to comment.