Skip to content
This repository was archived by the owner on Jan 24, 2022. It is now read-only.

Commit 661bdde

Browse files
authored
Reduce asm in Proxy.sol
1 parent abe30da commit 661bdde

File tree

1 file changed

+3
-16
lines changed
  • packages/lib/contracts/upgradeability

1 file changed

+3
-16
lines changed

packages/lib/contracts/upgradeability/Proxy.sol

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,10 @@ contract Proxy {
2828
* @param implementation Address to delegate.
2929
*/
3030
function _delegate(address implementation) internal {
31+
(bool success, bytes memory data) = implementation.delegatecall(msg.data);
32+
require(success, string(data));
3133
assembly {
32-
// Copy msg.data. We take full control of memory in this inline assembly
33-
// block because it will not return to Solidity code. We overwrite the
34-
// Solidity scratch pad at memory position 0.
35-
calldatacopy(0, 0, calldatasize)
36-
37-
// Call the implementation.
38-
// out and outsize are 0 because we don't know the size yet.
39-
let result := delegatecall(gas, implementation, 0, calldatasize, 0, 0)
40-
41-
// Copy the returned data.
42-
returndatacopy(0, 0, returndatasize)
43-
44-
switch result
45-
// delegatecall returns 0 on error.
46-
case 0 { revert(0, returndatasize) }
47-
default { return(0, returndatasize) }
34+
return(add(data, 32), sload(data))
4835
}
4936
}
5037

0 commit comments

Comments
 (0)