From 63994bcf03b114e9c25a4235871936e4e6d96082 Mon Sep 17 00:00:00 2001 From: GitGuru7 <128375421+GitGuru7@users.noreply.github.com> Date: Tue, 27 Feb 2024 14:40:27 +0530 Subject: [PATCH] fix: add natspec and shift tokenBridgeController to MintableTokenBridge --- contracts/Bridge/BaseTokenBridge.sol | 3 --- contracts/Bridge/MintableTokenBridge.sol | 16 ++++++++++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/contracts/Bridge/BaseTokenBridge.sol b/contracts/Bridge/BaseTokenBridge.sol index 6282546..b752ef5 100644 --- a/contracts/Bridge/BaseTokenBridge.sol +++ b/contracts/Bridge/BaseTokenBridge.sol @@ -22,7 +22,6 @@ import { ExponentialNoError } from "@venusprotocol/solidity-utilities/contracts/ abstract contract BaseTokenBridge is Pausable, ExponentialNoError, BaseOFTV2 { using SafeERC20 for IERC20; IERC20 internal immutable innerToken; - address internal immutable tokenBridgeController; bool public sendAndCallEnabled; uint256 internal immutable ld2sdRate; @@ -125,7 +124,6 @@ abstract contract BaseTokenBridge is Pausable, ExponentialNoError, BaseOFTV2 { */ constructor( address tokenAddress_, - address tokenBridgeController_, uint8 sharedDecimals_, address lzEndpoint_, address oracle_ @@ -135,7 +133,6 @@ abstract contract BaseTokenBridge is Pausable, ExponentialNoError, BaseOFTV2 { ensureNonzeroAddress(oracle_); innerToken = IERC20(tokenAddress_); - tokenBridgeController = tokenBridgeController_; (bool success, bytes memory data) = tokenAddress_.staticcall(abi.encodeWithSignature("decimals()")); require(success, "ProxyOFT: failed to get token decimals"); diff --git a/contracts/Bridge/MintableTokenBridge.sol b/contracts/Bridge/MintableTokenBridge.sol index 40c97b4..36c80db 100644 --- a/contracts/Bridge/MintableTokenBridge.sol +++ b/contracts/Bridge/MintableTokenBridge.sol @@ -19,6 +19,11 @@ contract MintableTokenBridge is BaseTokenBridge { */ bool public immutable isForceMintActive; + /** + * @notice Address of Token Bridge Controller. It can be zero address when token can be directly accessed. + */ + address public immutable tokenBridgeController; + /** * @notice Emits when stored message dropped without successful retrying. */ @@ -35,8 +40,9 @@ contract MintableTokenBridge is BaseTokenBridge { address lzEndpoint_, address oracle_, bool isForceMintActive_ - ) BaseTokenBridge(tokenAddress_, tokenBridgeController_, sharedDecimals_, lzEndpoint_, oracle_) { + ) BaseTokenBridge(tokenAddress_, sharedDecimals_, lzEndpoint_, oracle_) { isForceMintActive = isForceMintActive_; + tokenBridgeController = tokenBridgeController_; } /** @@ -65,6 +71,8 @@ contract MintableTokenBridge is BaseTokenBridge { require(isForceMintActive, "ProxyOFT: Force mint of token is not allowed on this chain"); ensureNonzeroAddress(to_); + + // When controller is used to interact with token if (tokenBridgeController != address(0)) { IMultichainToken(tokenBridgeController).mint(to_, amount_); } else { @@ -96,6 +104,8 @@ contract MintableTokenBridge is BaseTokenBridge { ) internal override whenNotPaused returns (uint256) { require(from_ == _msgSender(), "ProxyOFT: owner is not send caller"); _isEligibleToSend(from_, dstChainId_, amount_); + + // When controller is used to interact with token if (tokenBridgeController != address(0)) { IMultichainToken(tokenBridgeController).burn(from_, amount_); } else { @@ -117,6 +127,8 @@ contract MintableTokenBridge is BaseTokenBridge { uint256 amount_ ) internal override whenNotPaused returns (uint256) { _isEligibleToReceive(toAddress_, srcChainId_, amount_); + + // When controller is used to interact with token if (tokenBridgeController != address(0)) { IMultichainToken(tokenBridgeController).mint(toAddress_, amount_); } else { @@ -125,5 +137,5 @@ contract MintableTokenBridge is BaseTokenBridge { return amount_; } - function _transferFrom(address _from, address _to, uint _amount) internal virtual override returns (uint) {} + function _transferFrom(address from_, address to_, uint256 amount_) internal override returns (uint256) {} }