-
Notifications
You must be signed in to change notification settings - Fork 17
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
Foivos
wants to merge
7
commits into
feat/manual-migrate-tokens
Choose a base branch
from
feat/automcatic-migrate-tokens
base: feat/manual-migrate-tokens
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
58e956e
added automatic token migration
Foivos 6cd5926
Merge branch 'feat/manual-migrate-tokens' into feat/automcatic-migrat…
milapsheth 3c63b22
added a docstring
Foivos 70a0796
Merge branch 'feat/manual-migrate-tokens' into feat/automcatic-migrat…
Foivos b2b367b
fixed tests
Foivos 1f6eb3f
Merge branch 'feat/manual-migrate-tokens' into feat/automcatic-migrat…
Foivos 9c9f5f2
fix tests
Foivos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,8 +38,13 @@ contract TokenHandler is ITokenHandler, ITokenManagerType, ReentrancyGuard, Crea | |
/// @dev Track the flow amount being received via the message | ||
ITokenManager(tokenManager).addFlowIn(amount); | ||
|
||
if (tokenManagerType == uint256(TokenManagerType.NATIVE_INTERCHAIN_TOKEN)) { | ||
_migrateToken(tokenManager, tokenAddress); | ||
_mintToken(tokenManager, tokenAddress, to, amount); | ||
return (amount, tokenAddress); | ||
} | ||
|
||
if ( | ||
tokenManagerType == uint256(TokenManagerType.NATIVE_INTERCHAIN_TOKEN) || | ||
tokenManagerType == uint256(TokenManagerType.MINT_BURN) || | ||
tokenManagerType == uint256(TokenManagerType.MINT_BURN_FROM) | ||
) { | ||
|
@@ -75,9 +80,10 @@ contract TokenHandler is ITokenHandler, ITokenManagerType, ReentrancyGuard, Crea | |
|
||
if (tokenOnly && msg.sender != tokenAddress) revert NotToken(msg.sender, tokenAddress); | ||
|
||
if ( | ||
tokenManagerType == uint256(TokenManagerType.NATIVE_INTERCHAIN_TOKEN) || tokenManagerType == uint256(TokenManagerType.MINT_BURN) | ||
) { | ||
if (tokenManagerType == uint256(TokenManagerType.NATIVE_INTERCHAIN_TOKEN)) { | ||
_migrateToken(tokenManager, tokenAddress); | ||
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. same |
||
_burnToken(tokenManager, tokenAddress, from, amount); | ||
} else if (tokenManagerType == uint256(TokenManagerType.MINT_BURN)) { | ||
_burnToken(tokenManager, tokenAddress, from, amount); | ||
} else if (tokenManagerType == uint256(TokenManagerType.MINT_BURN_FROM)) { | ||
_burnTokenFrom(tokenAddress, from, amount); | ||
|
@@ -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 { | ||
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. add a docstring to explain this auto migration feature |
||
if (IMinter(tokenAddress).isMinter(address(this))) { | ||
IMinter(tokenAddress).transferMintership(tokenManager); | ||
} | ||
} | ||
} |
Oops, something went wrong.
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.
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.
call migrate separately so it's cleaner, gas cost difference should be very small
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.
you mean call it for every token type? indiscriminately? This would revert if the token in question does not implement
isMinter