Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into pack-gas-fees
Browse files Browse the repository at this point in the history
  • Loading branch information
drortirosh committed Jan 30, 2024
2 parents 04dae1f + a4ecd20 commit ab583ea
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion contracts/samples/TokenPaymaster.sol
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ contract TokenPaymaster is BasePaymaster, UniswapHelper, OracleHelper {
}

function withdrawEth(address payable recipient, uint256 amount) external onlyOwner {
recipient.call{value: amount}("");
(bool success,) = recipient.call{value: amount}("");
require(success, "withdraw failed");
}
}
8 changes: 4 additions & 4 deletions reports/gas-checker.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ paymaster+postOp with diff │ 11 │ │ 42693 │ 13714 ║
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ token paymaster │ 1 │ 128286 │ │ ║
║ token paymaster │ 1 │ 128274 │ │ ║
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ token paymaster with diff │ 2 │ │ 6589536916
║ token paymaster with diff │ 2 │ │ 6588336904
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ token paymaster │ 10 │ 721594 │ │ ║
║ token paymaster │ 10 │ 721582 │ │ ║
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ token paymaster with diff │ 11 │ │ 6591536936
║ token paymaster with diff │ 11 │ │ 6595136972
╚════════════════════════════════╧═══════╧═══════════════╧════════════════╧═════════════════════╝

4 changes: 4 additions & 0 deletions test/samples/TokenPaymaster.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,12 @@ describe('TokenPaymaster', function () {
const impersonatedSigner = await ethers.getImpersonatedSigner('0x1234567890123456789012345678901234567890')
const paymasterDifferentSigner = TokenPaymaster__factory.connect(paymasterAddress, impersonatedSigner)

// should revert for non owner
await expect(paymasterDifferentSigner.withdrawEth(paymasterOwner, amount)).to.be.revertedWith('OwnableUnauthorizedAccount')

// should revert if the transfer fails
await expect(paymaster.withdrawEth(recipient, BigNumber.from(amount).mul(2))).to.be.revertedWith('withdraw failed')

const recipientBalanceBefore = await ethers.provider.getBalance(recipient)
await paymaster.withdrawEth(recipient, balanceAfter)
const recipientBalanceAfter = await ethers.provider.getBalance(recipient)
Expand Down

0 comments on commit ab583ea

Please sign in to comment.