-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproxyContract.sol
More file actions
40 lines (31 loc) · 934 Bytes
/
proxyContract.sol
File metadata and controls
40 lines (31 loc) · 934 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
contract UUPSProxy {
address public implementation;
constructor(address _impl, bytes memory data) {
implementation = _impl;
if(data.length > 0){
(bool success,) = _impl.delegatecall(data);
require(success);
}
}
receive() external payable { }
fallback() external payable {
address impl = implementation;
assembly {
calldatacopy(0, 0, calldatasize())
let result := delegatecall(
gas(),
impl,
0,
calldatasize(),
0,
0
)
returndatacopy(0, 0, returndatasize())
switch result
case 0 { revert(0, returndatasize()) }
default { return(0, returndatasize()) }
}
}
}