pancakeswap / pancake-swap-periphery

GNU General Public License v3.0
191 stars 459 forks source link

Bug Report: Type Conversion from uint256 to address #28

Open lidd77 opened 2 years ago

lidd77 commented 2 years ago

hey,

when use address to convert uint , it prompts that "Cannot convert uint256 into address".

uint means uint256, address means bytes20, so this conversion in the pancakeSwap source codes should not work , but as I know , this code works for PancakeSwap .

what happened ? its for solidity compiler version?

  // calculates the CREATE2 address for a pair without making any external calls
    function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
        (address token0, address token1) = sortTokens(tokenA, tokenB);
        pair = address(uint(keccak256(abi.encodePacked(
                hex'ff',
                factory,
                keccak256(abi.encodePacked(token0, token1)),
                hex'd0d4c4cd0848c93cb4fd1f498d7013ee6bfb25783ea21593d5834f5d250ece66' // init code hash
            ))));
    }