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: emit NotBoundToken event #479

Merged
merged 2 commits into from
Jan 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion contracts/TokenHub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ contract TokenHub is ITokenHub, System, IParamSubscriber, IApplication, ISystemR
// BEP-299: Token Migration after BC Fusion
event TokenRecoverLocked(bytes32 indexed tokenSymbol, address indexed tokenAddr, address indexed recipient, uint256 amount, uint256 unlockAt);
event CancelTokenRecoverLock(bytes32 indexed tokenSymbol, address indexed tokenAddr, address indexed attacker, uint256 amount);
event NotBoundToken(bytes32 indexed tokenSymbol, address indexed recipient, uint256 amount);

// BEP-171: Security Enhancement for Cross-Chain Module
modifier onlyTokenOwner(address bep20Token) {
Expand Down Expand Up @@ -548,7 +549,13 @@ contract TokenHub is ITokenHub, System, IParamSubscriber, IApplication, ISystemR
uint256 convertedAmount;
if (tokenSymbol != BEP2_TOKEN_SYMBOL_FOR_BNB) {
address contractAddr = bep2SymbolToContractAddr[tokenSymbol];
require(contractAddr != address(0x00), "invalid symbol");
if (contractAddr == address(0x00)) {
// if the token is not bound, just emit an event
// please notify the token owner to handle the token recovery
emit NotBoundToken(tokenSymbol, recipient, amount);
return;
}

uint256 bep20TokenDecimals=bep20ContractDecimals[contractAddr];
convertedAmount = convertFromBep2Amount(amount, bep20TokenDecimals);// convert to bep20 amount
require(IBEP20(contractAddr).balanceOf(address(this)) >= convertedAmount, "insufficient balance");
Expand Down
Loading