Skip to content

Commit ed00cb8

Browse files
[Hebao1.1] check reimburse GasFee (#1638)
* [Hebao1.1] check reimburse GasFee * Update ForwarderModule.sol * Update ForwarderModule.sol Co-authored-by: Daniel Wang <[email protected]>
1 parent 96cc5f2 commit ed00cb8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/hebao_v1/contracts/modules/core/ForwarderModule.sol

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ pragma solidity ^0.7.0;
44
pragma experimental ABIEncoderV2;
55

66
import "../../lib/EIP712.sol";
7+
import "../../lib/ERC20.sol";
78
import "../../lib/MathUint.sol";
89
import "../../lib/SignatureUtil.sol";
910
import "../../thirdparty/BytesUtil.sol";
@@ -112,10 +113,13 @@ abstract contract ForwarderModule is BaseModule
112113
)
113114
{
114115
uint gasLeft = gasleft();
116+
uint gasLimit = (metaTx.gasLimit.mul(64) / 63).add(GAS_OVERHEAD);
117+
require(gasLeft >= gasLimit, "OPERATOR_INSUFFICIENT_GAS");
115118

119+
uint gasCost = gasLimit.mul(metaTx.gasPrice);
116120
require(
117-
gasLeft >= (metaTx.gasLimit.mul(64) / 63).add(GAS_OVERHEAD),
118-
"INSUFFICIENT_GAS"
121+
ERC20(metaTx.gasToken).balanceOf(metaTx.from) >= gasCost,
122+
"WALLET_INSUFFICIENT_GAS"
119123
);
120124

121125
// The trick is to append the really logical message sender and the

0 commit comments

Comments
 (0)