Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
openzeppelin-contracts-upgradeable
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
俞永鹏
openzeppelin-contracts-upgradeable
Commits
46881f71
Commit
46881f71
authored
Feb 01, 2021
by
Francisco Giordano
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'upstream-patched' into upstream-v3.4-patched
parents
0b6bfde4
bc6886c2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
85 additions
and
0 deletions
+85
-0
test.yml
.github/workflows/test.yml
+1
-0
AddressImpl.sol
contracts/mocks/AddressImpl.sol
+5
-0
Address.sol
contracts/utils/Address.sol
+24
-0
package-lock.json
package-lock.json
+0
-0
01-remove-address-functiondelegatecall.patch
...deable/patch/01-remove-address-functiondelegatecall.patch
+51
-0
transpile.sh
scripts/upgradeable/transpile.sh
+4
-0
No files found.
.github/workflows/test.yml
View file @
46881f71
...
@@ -6,6 +6,7 @@ on:
...
@@ -6,6 +6,7 @@ on:
-
master
-
master
-
release-v*
-
release-v*
pull_request
:
{}
pull_request
:
{}
workflow_dispatch
:
{}
jobs
:
jobs
:
test
:
test
:
...
...
contracts/mocks/AddressImpl.sol
View file @
46881f71
...
@@ -32,6 +32,11 @@ contract AddressImpl {
...
@@ -32,6 +32,11 @@ contract AddressImpl {
emit CallReturnValue(abi.decode(returnData, (string)));
emit CallReturnValue(abi.decode(returnData, (string)));
}
}
function functionDelegateCall(address target, bytes calldata data) external {
bytes memory returnData = Address.functionDelegateCall(target, data);
emit CallReturnValue(abi.decode(returnData, (string)));
}
// sendValue's tests require the contract to hold Ether
// sendValue's tests require the contract to hold Ether
receive () external payable { }
receive () external payable { }
}
}
contracts/utils/Address.sol
View file @
46881f71
...
@@ -144,6 +144,30 @@ library Address {
...
@@ -144,6 +144,30 @@ library Address {
return _verifyCallResult(success, returndata, errorMessage);
return _verifyCallResult(success, returndata, errorMessage);
}
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.3._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.3._
*/
function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.delegatecall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
if (success) {
return returndata;
return returndata;
...
...
package-lock.json
View file @
46881f71
This diff is collapsed.
Click to expand it.
scripts/upgradeable/patch/01-remove-address-functiondelegatecall.patch
0 → 100644
View file @
46881f71
diff --git a/contracts/mocks/AddressImplUpgradeable.sol b/contracts/mocks/AddressImplUpgradeable.sol
index e9a0f96f..2b87e58e 100644
--- a/contracts/mocks/AddressImplUpgradeable.sol
+++ b/contracts/mocks/AddressImplUpgradeable.sol
@@ -39,11 +39,6 @@ contract AddressImplUpgradeable is Initializable {
emit CallReturnValue(abi.decode(returnData, (string)));
}
- function functionDelegateCall(address target, bytes calldata data) external {
- bytes memory returnData = AddressUpgradeable.functionDelegateCall(target, data);
- emit CallReturnValue(abi.decode(returnData, (string)));
- }
-
// sendValue's tests require the contract to hold Ether
receive () external payable { }
uint256[49] private __gap;
diff --git a/contracts/utils/AddressUpgradeable.sol b/contracts/utils/AddressUpgradeable.sol
index 75acb96f..08a59041 100644
--- a/contracts/utils/AddressUpgradeable.sol
+++ b/contracts/utils/AddressUpgradeable.sol
@@ -144,30 +144,6 @@ library AddressUpgradeable {
return _verifyCallResult(success, returndata, errorMessage);
}
- /**
- * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
- * but performing a delegate call.
- *
- * _Available since v3.3._
- */
- function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
- return functionDelegateCall(target, data, "Address: low-level delegate call failed");
- }
-
- /**
- * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
- * but performing a delegate call.
- *
- * _Available since v3.3._
- */
- function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
- require(isContract(target), "Address: delegate call to non-contract");
-
- // solhint-disable-next-line avoid-low-level-calls
- (bool success, bytes memory returndata) = target.delegatecall(data);
- return _verifyCallResult(success, returndata, errorMessage);
- }
-
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
scripts/upgradeable/transpile.sh
View file @
46881f71
...
@@ -13,3 +13,7 @@ npx @openzeppelin/upgrade-safe-transpiler -D \
...
@@ -13,3 +13,7 @@ npx @openzeppelin/upgrade-safe-transpiler -D \
-x
'contracts/proxy/**/*'
\
-x
'contracts/proxy/**/*'
\
-x
'!contracts/proxy/Clones.sol'
\
-x
'!contracts/proxy/Clones.sol'
\
-p
'contracts/presets/**/*'
-p
'contracts/presets/**/*'
for
p
in
scripts/upgradeable/patch/
*
.patch
;
do
git apply
"
$p
"
done
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment