Skip to content
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: added automatic token migration #317

Open
wants to merge 7 commits into
base: feat/manual-migrate-tokens
Choose a base branch
from

Conversation

Foivos
Copy link
Contributor

@Foivos Foivos commented Jan 6, 2025

@Foivos Foivos requested a review from a team as a code owner January 6, 2025 14:16
Comment on lines 38 to 39
/// @dev Track the flow amount being received via the message
ITokenManager(tokenManager).addFlowIn(amount);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// @dev Track the flow amount being received via the message
ITokenManager(tokenManager).addFlowIn(amount);
_migrateToken(tokenManager, tokenAddress, tokenManagerType);
/// @dev Track the flow amount being received via the message
ITokenManager(tokenManager).addFlowIn(amount);

call migrate separately so it's cleaner, gas cost difference should be very small

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean call it for every token type? indiscriminately? This would revert if the token in question does not implement isMinter

@@ -172,4 +178,10 @@ contract TokenHandler is ITokenHandler, ITokenManagerType, ReentrancyGuard, Crea
function _burnTokenFrom(address tokenAddress, address from, uint256 amount) internal {
IERC20(tokenAddress).safeCall(abi.encodeWithSelector(IERC20BurnableFrom.burnFrom.selector, from, amount));
}

function _migrateToken(address tokenManager, address tokenAddress) internal {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a docstring to explain this auto migration feature

tokenManagerType == uint256(TokenManagerType.NATIVE_INTERCHAIN_TOKEN) || tokenManagerType == uint256(TokenManagerType.MINT_BURN)
) {
if (tokenManagerType == uint256(TokenManagerType.NATIVE_INTERCHAIN_TOKEN)) {
_migrateToken(tokenManager, tokenAddress);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

@codecov-commenter
Copy link

codecov-commenter commented Jan 9, 2025

Codecov Report

Attention: Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 99.06%. Comparing base (e4f3152) to head (9c9f5f2).

Files with missing lines Patch % Lines
contracts/TokenHandler.sol 91.66% 1 Missing ⚠️
Additional details and impacted files
@@                      Coverage Diff                       @@
##           feat/manual-migrate-tokens     #317      +/-   ##
==============================================================
- Coverage                       99.18%   99.06%   -0.13%     
==============================================================
  Files                              20       20              
  Lines                             740      746       +6     
  Branches                          175      174       -1     
==============================================================
+ Hits                              734      739       +5     
- Misses                              6        7       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants