Skip to content

Commit

Permalink
Redo fix for finding 3
Browse files Browse the repository at this point in the history
  • Loading branch information
lastperson committed Sep 9, 2024
1 parent f971a2b commit 15a1c1c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion contracts/handlers/ERC20Handler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ contract ERC20Handler is IHandler, ERCHandlerHelpers, DepositDataHelper, ERC20Sa
lockERC20(tokenAddress, depositor, address(this), amount);
}

return abi.encodePacked(convertToInternalBalance(tokenAddress, amount));
return convertToInternalBalance(tokenAddress, amount);
}

/**
Expand Down
7 changes: 4 additions & 3 deletions contracts/handlers/ERCHandlerHelpers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,19 @@ contract ERCHandlerHelpers is IERCHandler {
@notice Converts token amount based on decimal places difference from current network to bridge.
@param tokenAddress Address of contract to be used when executing proposals.
@param amount The token amount with decimals on the current network.
@return 32-length byte array with internal bridge amount OR empty byte array if conversion is not needed.
*/
function convertToInternalBalance(address tokenAddress, uint256 amount) internal view returns(uint256) {
function convertToInternalBalance(address tokenAddress, uint256 amount) internal view returns(bytes memory) {
Decimals memory decimals = _tokenContractAddressToTokenProperties[tokenAddress].decimals;
uint256 convertedBalance;
if (!decimals.isSet) {
convertedBalance = amount;
return "";
} else if (decimals.externalDecimals >= defaultDecimals) {
convertedBalance = amount / (10 ** (decimals.externalDecimals - defaultDecimals));
} else {
convertedBalance = amount * (10 ** (defaultDecimals - decimals.externalDecimals));
}

return convertedBalance;
return abi.encodePacked(convertedBalance);
}
}
2 changes: 1 addition & 1 deletion contracts/handlers/NativeTokenHandler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ contract NativeTokenHandler is IHandler, ERCHandlerHelpers, DepositDataHelper {

address tokenAddress = _resourceIDToTokenContractAddress[resourceID];

return abi.encodePacked(convertToInternalBalance(tokenAddress, amount));
return convertToInternalBalance(tokenAddress, amount);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion contracts/handlers/XC20Handler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ contract XC20Handler is IHandler, ERCHandlerHelpers, XC20Safe {
lockERC20(tokenAddress, depositor, address(this), amount);
}

return abi.encodePacked(convertToInternalBalance(tokenAddress, amount));
return convertToInternalBalance(tokenAddress, amount);
}

/**
Expand Down

0 comments on commit 15a1c1c

Please sign in to comment.