-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ensure we use the correct zone denom where evaluating pool claims #1721
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,7 +139,13 @@ func (*OsmosisModule) ValidateClaim(ctx sdk.Context, k *Keeper, msg *types.MsgSu | |
} | ||
} | ||
} | ||
sdkAmount, err := osmosistypes.DetermineApplicableTokensInPool(ctx, k, lock, msg.Zone) | ||
|
||
denom, found := k.ApplicableDenomForZone(ctx, msg.Zone) | ||
if !found { | ||
return math.ZeroInt(), errors.New("no applicable denom found for zone") | ||
} | ||
|
||
sdkAmount, err := osmosistypes.DetermineApplicableTokensInPool(ctx, k, lock, msg.Zone, denom) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Incomplete Update of The call in 🔗 Analysis chainEnsure all calls to The function Run the following script to find any usages of 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Find calls to `DetermineApplicableTokensInPool` without the `denom` parameter
# Expected: No occurrences of calls with missing parameters
rg --type go 'DetermineApplicableTokensInPool\(' -A5
Length of output: 1464 Script: #!/bin/bash
# Description: Verify if the 'denom' parameter is intentionally set to "UNUSED" in claim_handler.go
# Expected: Identify any comments or TODOs indicating the purpose of "UNUSED"
rg --type go 'DetermineApplicableTokensInPool\(' x/airdrop/keeper/claim_handler.go -A2
Length of output: 189 Script: #!/bin/bash
# Description: Search for definitions and usages of "UNUSED" in the codebase
# Expected: Identify if "UNUSED" is defined as a constant or used in multiple contexts
rg '"UNUSED"' --no-filename -C2
Length of output: 273 |
||
if err != nil { | ||
return sdk.ZeroInt(), err | ||
} | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -110,7 +110,12 @@ | |||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
sdkAmount, err := osmosistypes.DetermineApplicableTokensInClPool(ctx, k, position, msg.Zone) | ||||||||||||||||||||||||||
denom, found := k.ApplicableDenomForZone(ctx, msg.Zone) | ||||||||||||||||||||||||||
if !found { | ||||||||||||||||||||||||||
return math.ZeroInt(), errors.New("no applicable denom found for zone") | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
sdkAmount, err := osmosistypes.DetermineApplicableTokensInClPool(ctx, k, position, msg.Zone, denom) | ||||||||||||||||||||||||||
if err != nil { | ||||||||||||||||||||||||||
return math.ZeroInt(), err | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
@@ -126,3 +131,32 @@ | |||||||||||||||||||||||||
func (*OsmosisClModule) KeyPool(poolID uint64) []byte { | ||||||||||||||||||||||||||
return osmocl.KeyPool(poolID) | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
func (k *Keeper) ApplicableDenomForZone(ctx sdk.Context, chainId string) (denom string, found bool) { | ||||||||||||||||||||||||||
Check failure on line 135 in x/participationrewards/keeper/submodule_osmosiscl.go GitHub Actions / lint
|
||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct parameter name to follow Go naming conventions According to Go naming conventions, acronyms should be capitalized. Therefore, Apply this diff to correct the parameter name: -func (k *Keeper) ApplicableDenomForZone(ctx sdk.Context, chainId string) (denom string, found bool) {
+func (k *Keeper) ApplicableDenomForZone(ctx sdk.Context, chainID string) (denom string, found bool) { Also, update all instances of - zone, found := k.icsKeeper.GetZone(ctx, chainId)
+ zone, found := k.icsKeeper.GetZone(ctx, chainID) 📝 Committable suggestion
Suggested change
🧰 Tools🪛 GitHub Check: lint
|
||||||||||||||||||||||||||
zone, found := k.icsKeeper.GetZone(ctx, chainId) | ||||||||||||||||||||||||||
if !found { | ||||||||||||||||||||||||||
return "", false | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
params, found := k.GetProtocolData(ctx, types.ProtocolDataTypeOsmosisParams, types.OsmosisParamsKey) | ||||||||||||||||||||||||||
if !found { | ||||||||||||||||||||||||||
return "", false | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
paramsData := types.OsmosisParamsProtocolData{} | ||||||||||||||||||||||||||
if err := json.Unmarshal(params.Data, ¶msData); err != nil { | ||||||||||||||||||||||||||
return "", false | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
k.IteratePrefixedProtocolDatas(ctx, types.GetPrefixProtocolDataKey(types.ProtocolDataTypeLiquidToken), func(idx int64, key []byte, data types.ProtocolData) bool { | ||||||||||||||||||||||||||
liquidToken, _ := types.UnmarshalProtocolData(types.ProtocolDataTypeLiquidToken, data.Data) | ||||||||||||||||||||||||||
liquidTokenData := liquidToken.(*types.LiquidAllowedDenomProtocolData) | ||||||||||||||||||||||||||
Comment on lines
+152
to
+153
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Handle errors during unmarshalling and type assertion The error returned by Consider modifying the code to handle the error and safely perform the type assertion: - liquidToken, _ := types.UnmarshalProtocolData(types.ProtocolDataTypeLiquidToken, data.Data)
- liquidTokenData := liquidToken.(*types.LiquidAllowedDenomProtocolData)
+ liquidToken, err := types.UnmarshalProtocolData(types.ProtocolDataTypeLiquidToken, data.Data)
+ if err != nil {
+ // Handle the error appropriately, possibly log and continue
+ return false
+ }
+ liquidTokenData, ok := liquidToken.(*types.LiquidAllowedDenomProtocolData)
+ if !ok {
+ // Handle the unexpected type
+ return false
+ } 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||
if liquidTokenData.ChainID == paramsData.ChainID && liquidTokenData.QAssetDenom == zone.LocalDenom { | ||||||||||||||||||||||||||
found = true | ||||||||||||||||||||||||||
denom = liquidTokenData.IbcDenom | ||||||||||||||||||||||||||
return true | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
return false | ||||||||||||||||||||||||||
}) | ||||||||||||||||||||||||||
return denom, found | ||||||||||||||||||||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use
sdk.ZeroInt()
instead ofmath.ZeroInt()
for error returnIn line 145, you return
math.ZeroInt()
, whereas elsewhere in the code,sdk.ZeroInt()
is used for returning zeroInt
values. For consistency and to avoid potential issues, consider replacingmath.ZeroInt()
withsdk.ZeroInt()
.Apply this diff to fix the inconsistency:
📝 Committable suggestion