Skip to content

Commit

Permalink
Move Context from GSN to utils directory (#2453)
Browse files Browse the repository at this point in the history
Co-authored-by: Hadrien Croubois <hadrien@openzeppelin.com>
Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
  • Loading branch information
3 people authored Jan 7, 2021
1 parent b6e5187 commit 318c4b4
Show file tree
Hide file tree
Showing 22 changed files with 45 additions and 39 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* `ERC20Permit`: added an implementation of the ERC20 permit extension for gasless token approvals. ([#2237](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2237))
* Presets: added token presets with preminted fixed supply `ERC20PresetFixedSupply` and `ERC777PresetFixedSupply`. ([#2399](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2399))
* `Address`: added `functionDelegateCall`, similar to the existing `functionCall`. ([#2333](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2333))
* `Context`: moved from `contracts/GSN` to `contracts/utils`. ([#2453](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2453))
* `PaymentSplitter`: replace usage of `.transfer()` with `Address.sendValue` for improved compatibility with smart wallets. ([#2455](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2455))
* `UpgradeableProxy`: bubble revert reasons from initialization calls. ([#2454](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2454))

Expand Down
21 changes: 1 addition & 20 deletions contracts/GSN/Context.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,4 @@

pragma solidity >=0.6.0 <0.8.0;

/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with GSN meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}

function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
import "../utils/Context.sol";
2 changes: 1 addition & 1 deletion contracts/GSN/GSNRecipient.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

pragma solidity >=0.6.0 <0.8.0;

import "../utils/Context.sol";
import "./IRelayRecipient.sol";
import "./IRelayHub.sol";
import "./Context.sol";

/**
* @dev Base GSN recipient contract: includes the {IRelayRecipient} interface
Expand Down
2 changes: 1 addition & 1 deletion contracts/access/AccessControl.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity >=0.6.0 <0.8.0;

import "../utils/EnumerableSet.sol";
import "../utils/Address.sol";
import "../GSN/Context.sol";
import "../utils/Context.sol";

/**
* @dev Contract module that allows children to implement role-based access
Expand Down
2 changes: 1 addition & 1 deletion contracts/access/Ownable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pragma solidity >=0.6.0 <0.8.0;

import "../GSN/Context.sol";
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/ContextMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pragma solidity >=0.6.0 <0.8.0;

import "../GSN/Context.sol";
import "../utils/Context.sol";

contract ContextMock is Context {
event Sender(address sender);
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/ERC777Mock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pragma solidity >=0.6.0 <0.8.0;

import "../GSN/Context.sol";
import "../utils/Context.sol";
import "../token/ERC777/ERC777.sol";

contract ERC777Mock is Context, ERC777 {
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/ERC777SenderRecipientMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pragma solidity >=0.6.0 <0.8.0;

import "../GSN/Context.sol";
import "../utils/Context.sol";
import "../token/ERC777/IERC777.sol";
import "../token/ERC777/IERC777Sender.sol";
import "../token/ERC777/IERC777Recipient.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/ReentrancyAttack.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pragma solidity >=0.6.0 <0.8.0;

import "../GSN/Context.sol";
import "../utils/Context.sol";
contract ReentrancyAttack is Context {
function callSender(bytes4 data) public {
// solhint-disable-next-line avoid-low-level-calls
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/SafeERC20Helper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pragma solidity >=0.6.0 <0.8.0;

import "../GSN/Context.sol";
import "../utils/Context.sol";
import "../token/ERC20/IERC20.sol";
import "../token/ERC20/SafeERC20.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/payment/PaymentSplitter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pragma solidity >=0.6.0 <0.8.0;

import "../GSN/Context.sol";
import "../utils/Context.sol";
import "../math/SafeMath.sol";
import "../utils/Address.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/presets/ERC1155PresetMinterPauser.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pragma solidity >=0.6.0 <0.8.0;

import "../access/AccessControl.sol";
import "../GSN/Context.sol";
import "../utils/Context.sol";
import "../token/ERC1155/ERC1155.sol";
import "../token/ERC1155/ERC1155Burnable.sol";
import "../token/ERC1155/ERC1155Pausable.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/presets/ERC20PresetMinterPauser.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pragma solidity >=0.6.0 <0.8.0;

import "../access/AccessControl.sol";
import "../GSN/Context.sol";
import "../utils/Context.sol";
import "../token/ERC20/ERC20.sol";
import "../token/ERC20/ERC20Burnable.sol";
import "../token/ERC20/ERC20Pausable.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/presets/ERC721PresetMinterPauserAutoId.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pragma solidity >=0.6.0 <0.8.0;

import "../access/AccessControl.sol";
import "../GSN/Context.sol";
import "../utils/Context.sol";
import "../utils/Counters.sol";
import "../token/ERC721/ERC721.sol";
import "../token/ERC721/ERC721Burnable.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/token/ERC1155/ERC1155.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pragma solidity >=0.6.0 <0.8.0;
import "./IERC1155.sol";
import "./IERC1155MetadataURI.sol";
import "./IERC1155Receiver.sol";
import "../../GSN/Context.sol";
import "../../utils/Context.sol";
import "../../introspection/ERC165.sol";
import "../../math/SafeMath.sol";
import "../../utils/Address.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/token/ERC20/ERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pragma solidity >=0.6.0 <0.8.0;

import "../../GSN/Context.sol";
import "../../utils/Context.sol";
import "./IERC20.sol";
import "../../math/SafeMath.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/token/ERC20/ERC20Burnable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pragma solidity >=0.6.0 <0.8.0;

import "../../GSN/Context.sol";
import "../../utils/Context.sol";
import "./ERC20.sol";

/**
Expand Down
2 changes: 1 addition & 1 deletion contracts/token/ERC721/ERC721.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pragma solidity >=0.6.0 <0.8.0;

import "../../GSN/Context.sol";
import "../../utils/Context.sol";
import "./IERC721.sol";
import "./IERC721Metadata.sol";
import "./IERC721Enumerable.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/token/ERC721/ERC721Burnable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pragma solidity >=0.6.0 <0.8.0;

import "../../GSN/Context.sol";
import "../../utils/Context.sol";
import "./ERC721.sol";

/**
Expand Down
2 changes: 1 addition & 1 deletion contracts/token/ERC777/ERC777.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pragma solidity >=0.6.0 <0.8.0;

import "../../GSN/Context.sol";
import "../../utils/Context.sol";
import "./IERC777.sol";
import "./IERC777Recipient.sol";
import "./IERC777Sender.sol";
Expand Down
24 changes: 24 additions & 0 deletions contracts/utils/Context.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with GSN meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}

function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
2 changes: 1 addition & 1 deletion contracts/utils/Pausable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pragma solidity >=0.6.0 <0.8.0;

import "../GSN/Context.sol";
import "./Context.sol";

/**
* @dev Contract module which allows children to implement an emergency stop
Expand Down

0 comments on commit 318c4b4

Please sign in to comment.