-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Remove code in preparation for v5.0 #4258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
cd07e1b
Remove cross-chain contracts
Amxx 42b3aef
Remove Escrow & PullPayment contracts
Amxx ff68a57
Remove ERC777
Amxx 18e63a7
Update documentation's nav
Amxx 64bf67c
add changeset
Amxx aeb12fa
Remove the Timer libary
Amxx 0ea8756
Remove deprecated draft-xxx files.
Amxx 3344612
Remove getters with error strings
Amxx 5624e52
Remove SafeERC20.safeApprove
Amxx 0a3ccc2
Remove AccessControl._setupRole
Amxx f3e4e14
Remove deprecated getters in Proxy & deprecated error code in ECDSA
Amxx a06d55f
Remove GovernorProposalThreshold
Amxx a949b62
Remove ERC1820Implementer
Amxx 6831f92
fix lint
Amxx 7b385c6
remove tests for ERC1820Implementer
Amxx cd0407f
fix test/urils/Create2.test.js dependency on ERC1820Implementer
Amxx edc27fe
remove deprecated and duplicate storage
Amxx 69c5dee
Remove Checkpoints.History
Amxx c974e7f
Remove SafeMath.sol and move tryXxx function to Math.sol
Amxx d39ab48
re-add PullPayment (with immutable ownership of the Escrow)
Amxx b2be20e
Revert "re-add PullPayment (with immutable ownership of the Escrow)"
Amxx f714926
Update "_Available since" for tryXxx operations
Amxx 15639d7
Apply suggestions from code review
Amxx e519bc3
Update Math.test.js
Amxx 2cd0d41
cleanup EnumerableMap.test.js
Amxx 815bf2a
cleanup Checkpoints tests
Amxx a19eb6a
retreive checkpoint sizes from the generation scripts
Amxx d0e778f
fix foundry test
Amxx 932ae59
Fix upgradeable.patch
Amxx b9991cc
Update .changeset/selfish-queens-rest.md
Amxx 4d11483
add missing await
frangio 32b6b60
Remove SignedSafeMath library and tests
Amxx e21211b
remove mention to SafeMath in SafeCast
Amxx 9456fce
Update test/utils/Create2.test.js
Amxx 2d2e8fa
Update test/utils/Checkpoints.test.js
frangio 9193cea
remove mention of safemath from template
frangio 41732d3
remove ERC-1820 docs and move interfaces
frangio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
re-add PullPayment (with immutable ownership of the Escrow)
- Loading branch information
commit d39ab48fd146f6244599cfeeb4c4b83171f2acdc
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| // OpenZeppelin Contracts (last updated v4.8.0) (security/PullPayment.sol) | ||
|
|
||
| pragma solidity ^0.8.0; | ||
|
|
||
| import "./PullPaymentEscrow.sol"; | ||
|
|
||
| /** | ||
| * @dev Simple implementation of a | ||
| * https://consensys.github.io/smart-contract-best-practices/development-recommendations/general/external-calls/#favor-pull-over-push-for-external-calls[pull-payment] | ||
| * strategy, where the paying contract doesn't interact directly with the | ||
| * receiver account, which must withdraw its payments itself. | ||
| * | ||
| * Pull-payments are often considered the best practice when it comes to sending | ||
| * Ether, security-wise. It prevents recipients from blocking execution, and | ||
| * eliminates reentrancy concerns. | ||
| * | ||
| * TIP: If you would like to learn more about reentrancy and alternative ways | ||
| * to protect against it, check out our blog post | ||
| * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. | ||
| * | ||
| * To use, derive from the `PullPayment` contract, and use {_asyncTransfer} | ||
| * instead of Solidity's `transfer` function. Payees can query their due | ||
| * payments with {payments}, and retrieve them with {withdrawPayments}. | ||
| */ | ||
| abstract contract PullPayment { | ||
| PullPaymentEscrow private immutable _escrow = new PullPaymentEscrow(); | ||
|
|
||
| /** | ||
| * @dev Withdraw accumulated payments, forwarding all gas to the recipient. | ||
| * | ||
| * Note that _any_ account can call this function, not just the `payee`. | ||
| * This means that contracts unaware of the `PullPayment` protocol can still | ||
| * receive funds this way, by having a separate account call | ||
| * {withdrawPayments}. | ||
| * | ||
| * WARNING: Forwarding all gas opens the door to reentrancy vulnerabilities. | ||
| * Make sure you trust the recipient, or are either following the | ||
| * checks-effects-interactions pattern or using {ReentrancyGuard}. | ||
| * | ||
| * @param payee Whose payments will be withdrawn. | ||
| * | ||
| * Causes the `escrow` to emit a {Withdrawn} event. | ||
| */ | ||
| function withdrawPayments(address payable payee) public virtual { | ||
| _escrow.withdraw(payee); | ||
| } | ||
|
|
||
| /** | ||
| * @dev Returns the payments owed to an address. | ||
| * @param dest The creditor's address. | ||
| */ | ||
| function payments(address dest) public view returns (uint256) { | ||
| return _escrow.depositsOf(dest); | ||
| } | ||
|
|
||
| /** | ||
| * @dev Called by the payer to store the sent amount as credit to be pulled. | ||
| * Funds sent in this way are stored in an intermediate {Escrow} contract, so | ||
| * there is no danger of them being spent before withdrawal. | ||
| * | ||
| * @param dest The destination address of the funds. | ||
| * @param amount The amount to transfer. | ||
| * | ||
| * Causes the `escrow` to emit a {Deposited} event. | ||
| */ | ||
| function _asyncTransfer(address dest, uint256 amount) internal virtual { | ||
| _escrow.deposit{value: amount}(dest); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| // OpenZeppelin Contracts (last updated v4.7.0) (utils/escrow/Escrow.sol) | ||
|
|
||
| pragma solidity ^0.8.0; | ||
|
|
||
| import "../utils/Address.sol"; | ||
| import "../utils/Context.sol"; | ||
|
|
||
| /** | ||
| * @title Escrow | ||
| * @dev Base escrow contract, holds funds designated for a payee until they | ||
| * withdraw them. | ||
| * | ||
| * Intended usage: This contract (and derived escrow contracts) should be a | ||
| * standalone contract, that only interacts with the contract that instantiated | ||
| * it. That way, it is guaranteed that all Ether will be handled according to | ||
| * the `Escrow` rules, and there is no need to check for payable functions or | ||
| * transfers in the inheritance tree. The contract that uses the escrow as its | ||
| * payment method should be its owner, and provide public methods redirecting | ||
| * to the escrow's deposit and withdraw. | ||
| */ | ||
| contract PullPaymentEscrow is Context { | ||
| using Address for address payable; | ||
|
|
||
| address public immutable owner = msg.sender; | ||
|
|
||
| event Deposited(address indexed payee, uint256 weiAmount); | ||
| event Withdrawn(address indexed payee, uint256 weiAmount); | ||
|
|
||
| mapping(address => uint256) private _deposits; | ||
|
|
||
| modifier onlyOwner() { | ||
| require(owner == _msgSender(), "Ownable: caller is not the owner"); | ||
| _; | ||
| } | ||
|
|
||
| function depositsOf(address payee) public view returns (uint256) { | ||
| return _deposits[payee]; | ||
| } | ||
|
|
||
| /** | ||
| * @dev Stores the sent amount as credit to be withdrawn. | ||
| * @param payee The destination address of the funds. | ||
| * | ||
| * Emits a {Deposited} event. | ||
| */ | ||
| function deposit(address payee) public payable virtual onlyOwner { | ||
| uint256 amount = msg.value; | ||
| _deposits[payee] += amount; | ||
| emit Deposited(payee, amount); | ||
| } | ||
|
|
||
| /** | ||
| * @dev Withdraw accumulated balance for a payee, forwarding all gas to the | ||
| * recipient. | ||
| * | ||
| * WARNING: Forwarding all gas opens the door to reentrancy vulnerabilities. | ||
| * Make sure you trust the recipient, or are either following the | ||
| * checks-effects-interactions pattern or using {ReentrancyGuard}. | ||
| * | ||
| * @param payee The address whose funds will be withdrawn and transferred to. | ||
| * | ||
| * Emits a {Withdrawn} event. | ||
| */ | ||
| function withdraw(address payable payee) public virtual onlyOwner { | ||
| uint256 payment = _deposits[payee]; | ||
|
|
||
| _deposits[payee] = 0; | ||
|
|
||
| payee.sendValue(payment); | ||
|
|
||
| emit Withdrawn(payee, payment); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| const { balance, ether } = require('@openzeppelin/test-helpers'); | ||
|
|
||
| const { expect } = require('chai'); | ||
|
|
||
| const PullPaymentMock = artifacts.require('$PullPayment'); | ||
|
|
||
| contract('PullPayment', function (accounts) { | ||
| const [payer, payee1, payee2] = accounts; | ||
|
|
||
| const amount = ether('17'); | ||
|
|
||
| beforeEach(async function () { | ||
| this.contract = await PullPaymentMock.new(); | ||
| await web3.eth.sendTransaction({ from: payer, to: this.contract.address, value: amount }); | ||
| }); | ||
|
|
||
| describe('payments', function () { | ||
| it('can record an async payment correctly', async function () { | ||
| await this.contract.$_asyncTransfer(payee1, 100, { from: payer }); | ||
| expect(await this.contract.payments(payee1)).to.be.bignumber.equal('100'); | ||
| }); | ||
|
|
||
| it('can add multiple balances on one account', async function () { | ||
| await this.contract.$_asyncTransfer(payee1, 200, { from: payer }); | ||
| await this.contract.$_asyncTransfer(payee1, 300, { from: payer }); | ||
| expect(await this.contract.payments(payee1)).to.be.bignumber.equal('500'); | ||
| }); | ||
|
|
||
| it('can add balances on multiple accounts', async function () { | ||
| await this.contract.$_asyncTransfer(payee1, 200, { from: payer }); | ||
| await this.contract.$_asyncTransfer(payee2, 300, { from: payer }); | ||
|
|
||
| expect(await this.contract.payments(payee1)).to.be.bignumber.equal('200'); | ||
|
|
||
| expect(await this.contract.payments(payee2)).to.be.bignumber.equal('300'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('withdrawPayments', function () { | ||
| it('can withdraw payment', async function () { | ||
| const balanceTracker = await balance.tracker(payee1); | ||
|
|
||
| await this.contract.$_asyncTransfer(payee1, amount, { from: payer }); | ||
| expect(await this.contract.payments(payee1)).to.be.bignumber.equal(amount); | ||
|
|
||
| await this.contract.withdrawPayments(payee1); | ||
|
|
||
| expect(await balanceTracker.delta()).to.be.bignumber.equal(amount); | ||
| expect(await this.contract.payments(payee1)).to.be.bignumber.equal('0'); | ||
| }); | ||
| }); | ||
| }); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.