Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
feat: add foreign assets support on asset hubs, such as MYTH on PAH #1577
feat: add foreign assets support on asset hubs, such as MYTH on PAH #1577
Changes from 1 commit
22c373b
0f81f37
fa547aa
97a26b8
57b3a36
e224376
98e971c
bc5e750
cbe417c
e13d209
70eca03
cf88550
c26d3d4
1ad4c50
4b37252
b628f90
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
🛠️ Refactor suggestion
Simplify property access with optional chaining
In the assignment of
isForeignAsset
, you can use optional chaining to simplify the code and handle cases whereassetId
isundefined
:This makes the code more concise and reduces the risk of errors.
Apply this diff:
🧰 Tools
🪛 Biome
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.
Avoid checking for 'undefined' as a string
In the
parsedAssetId
assignment, the code checks ifassetId
equals'undefined'
as a string:Having
'undefined'
as a string suggests that somewhereassetId
may be set to the string'undefined'
instead of beingundefined
. This could lead to unexpected behavior. It's recommended to ensureassetId
is eitherundefined
or a valid string representing an asset ID.Apply this diff to remove the string comparison and handle the potential issue at the source where
assetId
may be set to'undefined'
: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.
🛠️ Refactor suggestion
Refactor nested ternary operators for readability
The nested ternary operators used to determine the
module
variable could be simplified for better readability:Consider refactoring using if-else statements or a more readable approach to enhance code clarity.
Suggested refactor:
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.
Improve error handling in the try-catch block
In the catch block, consider providing more informative error messages or handling specific exceptions to aid in debugging:
Apply this diff:
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.
Handle potential negative values in amount calculation
In the
setWholeAmount
function, when calculatingallAmount
, ensure that subtracting_maxFee
fromtransferableBalance
does not result in negative values, which could cause issues when converting to a human-readable amount.Consider adding a check to ensure the result is not negative: