Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions packages/hebao_v1/contracts/base/BaseWallet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,10 @@ abstract contract BaseWallet is ReentrancyGuard, Wallet
// This call is introduced to support reentrany check.
// The caller shall NOT have the nonReentrant modifier.
function nonReentrantCall(
uint8 mode,
address target,
uint value,
bytes memory data
uint8 mode,
address target,
uint value,
bytes calldata data
)
private
nonReentrant
Expand Down
47 changes: 46 additions & 1 deletion packages/hebao_v1/contracts/lib/AddressUtil.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ library AddressUtil
pure
returns (address payable)
{
return address(uint160(addr));
return payable(addr);
}

// Works like address.send but with a customizable gas limit
Expand Down Expand Up @@ -68,4 +68,49 @@ library AddressUtil
success = to.sendETH(amount, gasLimit);
require(success, "TRANSFER_FAILURE");
}

// Works like call but is slightly more efficient when data
// needs to be copied from memory to do the call.
function fastCall(
address to,
uint gasLimit,
uint value,
bytes memory data
)
internal
returns (bool success, bytes memory returnData)
{
if (to != address(0)) {
assembly {
// Do the call
success := call(gasLimit, to, value, add(data, 32), mload(data), 0, 0)
// Copy the return data
let size := returndatasize()
returnData := mload(0x40)
mstore(returnData, size)
returndatacopy(add(returnData, 32), 0, size)
// Update free memory pointer
mstore(0x40, add(returnData, add(32, size)))
}
}
}

// Like fastCall, but throws when the call is unsuccessful.
function fastCallAndVerify(
address to,
uint gasLimit,
uint value,
bytes memory data
)
internal
returns (bytes memory returnData)
{
bool success;
(success, returnData) = fastCall(to, gasLimit, value, data);
if (!success) {
assembly {
revert(add(returnData, 32), mload(returnData))
}
}
}
}
4 changes: 2 additions & 2 deletions packages/hebao_v1/contracts/modules/base/BaseModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ abstract contract BaseModule is ReentrancyGuard, Module
address wallet,
address to,
uint value,
bytes memory data
bytes calldata data
)
internal
returns (bytes memory)
Expand All @@ -195,7 +195,7 @@ abstract contract BaseModule is ReentrancyGuard, Module
function transactStaticCall(
address wallet,
address to,
bytes memory data
bytes calldata data
)
internal
returns (bytes memory)
Expand Down
2 changes: 2 additions & 0 deletions packages/hebao_v1/contracts/modules/core/ForwarderModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

import "../../lib/AddressUtil.sol";
import "../../lib/EIP712.sol";
import "../../lib/ERC20.sol";
import "../../lib/MathUint.sol";
Expand All @@ -17,6 +18,7 @@ import "./WalletFactory.sol";
/// @author Daniel Wang - <daniel@loopring.org>
abstract contract ForwarderModule is BaseModule
{
using AddressUtil for address;
using BytesUtil for bytes;
using MathUint for uint;
using SignatureUtil for bytes32;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ abstract contract BaseTransferModule is SecurityModule
address token,
address to,
uint amount,
bytes memory logdata
bytes calldata logdata
)
internal
{
Expand Down Expand Up @@ -80,7 +80,7 @@ abstract contract BaseTransferModule is SecurityModule
address wallet,
address to,
uint value,
bytes memory txData
bytes calldata txData
)
internal
virtual
Expand Down
4 changes: 2 additions & 2 deletions packages/hebao_v1/contracts/thirdparty/ens/BaseENSManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ contract BaseENSManager is IENSManager, OwnerManagable, ENSConsumer {
function verifyApproval(
address _wallet,
address _owner,
string memory _label,
bytes memory _approval
string calldata _label,
bytes calldata _approval
)
internal
view
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ contract QuotaTransfers is TransferModule
address wallet,
address to,
uint value,
bytes memory txData
bytes calldata txData
)
internal
override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ abstract contract TransferModule is SecurityModule
address wallet,
address to,
uint value,
bytes memory txData
bytes calldata txData
)
internal
virtual
Expand Down
45 changes: 45 additions & 0 deletions packages/loopring_v3/contracts/lib/AddressUtil.sol
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,49 @@ library AddressUtil
success = to.sendETH(amount, gasLimit);
require(success, "TRANSFER_FAILURE");
}

// Works like call but is slightly more efficient when data
// needs to be copied from memory to do the call.
function fastCall(
address to,
uint gasLimit,
uint value,
bytes memory data
)
internal
returns (bool success, bytes memory returnData)
{
if (to != address(0)) {
assembly {
// Do the call
success := call(gasLimit, to, value, add(data, 32), mload(data), 0, 0)
// Copy the return data
let size := returndatasize()
returnData := mload(0x40)
mstore(returnData, size)
returndatacopy(add(returnData, 32), 0, size)
// Update free memory pointer
mstore(0x40, add(returnData, add(32, size)))
}
}
}

// Like fastCall, but throws when the call is unsuccessful.
function fastCallAndVerify(
address to,
uint gasLimit,
uint value,
bytes memory data
)
internal
returns (bytes memory returnData)
{
bool success;
(success, returnData) = fastCall(to, gasLimit, value, data);
if (!success) {
assembly {
revert(add(returnData, 32), mload(returnData))
}
}
}
}