From 23e849cfcb3a7dca088ade4150908af7883427f4 Mon Sep 17 00:00:00 2001 From: j75689 Date: Mon, 29 Jan 2024 10:11:50 +0800 Subject: [PATCH 1/2] feat: emit NotBoundToken event --- contracts/TokenHub.sol | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/contracts/TokenHub.sol b/contracts/TokenHub.sol index 8e06f2a0..ddf3618b 100644 --- a/contracts/TokenHub.sol +++ b/contracts/TokenHub.sol @@ -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) { @@ -548,7 +549,11 @@ 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)) { + 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"); From d6a2b9bbf9767daaa5eef8ee4089464b6224a35f Mon Sep 17 00:00:00 2001 From: j75689 Date: Mon, 29 Jan 2024 10:15:23 +0800 Subject: [PATCH 2/2] chore: add comments --- contracts/TokenHub.sol | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contracts/TokenHub.sol b/contracts/TokenHub.sol index ddf3618b..c792c61b 100644 --- a/contracts/TokenHub.sol +++ b/contracts/TokenHub.sol @@ -550,6 +550,8 @@ contract TokenHub is ITokenHub, System, IParamSubscriber, IApplication, ISystemR if (tokenSymbol != BEP2_TOKEN_SYMBOL_FOR_BNB) { address contractAddr = bep2SymbolToContractAddr[tokenSymbol]; 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; }