Skip to content

Commit bb4d02b

Browse files
[hebao_v1]gas recipient refine (#1321)
* gas recipient refine * update
1 parent 4ba3ac8 commit bb4d02b

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

packages/hebao_v1/contracts/base/MetaTxModule.sol

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ abstract contract MetaTxModule is BaseModule
188188
address(gasSetting[4])
189189
);
190190
require(gasSettings.limit > 0, "INVALID_GAS_LIMIT");
191+
require(gasSettings.recipient == controller.collectTo(), "INVALID_GAS_RECIPIENT");
191192

192193
address wallet = extractWalletAddress(data);
193194
bytes32 metaTxHash = EIP712.hashPacked(
@@ -232,7 +233,7 @@ abstract contract MetaTxModule is BaseModule
232233

233234
emit MetaTxExecuted(msg.sender, wallet, nonce, metaTxHash, gasUsed, success, returnData);
234235

235-
if (gasSettings.price != 0) {
236+
if (gasSettings.price != 0 && reimbursable(extractMethod(data))) {
236237
reimburseGasFee(wallet, gasSettings, gasUsed);
237238
}
238239
}
@@ -301,6 +302,14 @@ abstract contract MetaTxModule is BaseModule
301302
return (signers.length == 1 && signers[0] == signer);
302303
}
303304

305+
function reimbursable(bytes4 method)
306+
internal
307+
view
308+
virtual
309+
returns (bool) {
310+
return true;
311+
}
312+
304313
/// @dev For all relayed method, the first parameter must be the wallet address.
305314
function extractWalletAddress(bytes memory data)
306315
internal
@@ -392,7 +401,7 @@ abstract contract MetaTxModule is BaseModule
392401
uint gasCost = gasUsed.add(gasSettings.overhead).mul(gasSettings.price);
393402
updateQuota(wallet, gasSettings.token, gasCost);
394403

395-
address feeRecipient = (gasSettings.recipient == address(0)) ? msg.sender : gasSettings.recipient;
404+
address feeRecipient = gasSettings.recipient;
396405
if (gasSettings.token == address(0)) {
397406
transactCall(wallet, feeRecipient, gasCost, "");
398407
} else {

packages/hebao_v1/contracts/modules/security/GuardianModule.sol

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,4 +229,18 @@ contract GuardianModule is SecurityModule
229229
revert("INVALID_METHOD");
230230
}
231231
}
232+
233+
function reimbursable(bytes4 method)
234+
internal
235+
view
236+
override
237+
returns (bool) {
238+
if (method == this.lock.selector || method == this.unlock.selector) {
239+
return false;
240+
} else {
241+
return true;
242+
}
243+
244+
}
245+
232246
}

0 commit comments

Comments
 (0)