@layerzerolabs/proxy-v5-6-evm-contracts 1.2.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/.turbo/turbo-build.log +270 -0
  2. package/.turbo/turbo-lint.log +98 -0
  3. package/.turbo/turbo-test.log +124 -0
  4. package/LICENSE +23 -0
  5. package/artifacts/@openzeppelin/contracts/access/Ownable.sol/Ownable.dbg.json +4 -0
  6. package/artifacts/@openzeppelin/contracts/access/Ownable.sol/Ownable.json +85 -0
  7. package/artifacts/@openzeppelin/contracts/access/Ownable2Step.sol/Ownable2Step.dbg.json +4 -0
  8. package/artifacts/@openzeppelin/contracts/access/Ownable2Step.sol/Ownable2Step.json +124 -0
  9. package/artifacts/@openzeppelin/contracts/interfaces/IERC1967.sol/IERC1967.dbg.json +4 -0
  10. package/artifacts/@openzeppelin/contracts/interfaces/IERC1967.sol/IERC1967.json +56 -0
  11. package/artifacts/@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol/ERC1967Proxy.dbg.json +4 -0
  12. package/artifacts/@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol/ERC1967Proxy.json +81 -0
  13. package/artifacts/@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol/ERC1967Utils.dbg.json +4 -0
  14. package/artifacts/@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol/ERC1967Utils.json +49 -0
  15. package/artifacts/@openzeppelin/contracts/proxy/Proxy.sol/Proxy.dbg.json +4 -0
  16. package/artifacts/@openzeppelin/contracts/proxy/Proxy.sol/Proxy.json +15 -0
  17. package/artifacts/@openzeppelin/contracts/proxy/beacon/IBeacon.sol/IBeacon.dbg.json +4 -0
  18. package/artifacts/@openzeppelin/contracts/proxy/beacon/IBeacon.sol/IBeacon.json +24 -0
  19. package/artifacts/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol/ProxyAdmin.dbg.json +4 -0
  20. package/artifacts/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol/ProxyAdmin.json +132 -0
  21. package/artifacts/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/ITransparentUpgradeableProxy.dbg.json +4 -0
  22. package/artifacts/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/ITransparentUpgradeableProxy.json +74 -0
  23. package/artifacts/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy.dbg.json +4 -0
  24. package/artifacts/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy.json +121 -0
  25. package/artifacts/@openzeppelin/contracts/utils/Address.sol/Address.dbg.json +4 -0
  26. package/artifacts/@openzeppelin/contracts/utils/Address.sol/Address.json +22 -0
  27. package/artifacts/@openzeppelin/contracts/utils/Context.sol/Context.dbg.json +4 -0
  28. package/artifacts/@openzeppelin/contracts/utils/Context.sol/Context.json +10 -0
  29. package/artifacts/@openzeppelin/contracts/utils/Errors.sol/Errors.dbg.json +4 -0
  30. package/artifacts/@openzeppelin/contracts/utils/Errors.sol/Errors.json +48 -0
  31. package/artifacts/@openzeppelin/contracts/utils/LowLevelCall.sol/LowLevelCall.dbg.json +4 -0
  32. package/artifacts/@openzeppelin/contracts/utils/LowLevelCall.sol/LowLevelCall.json +10 -0
  33. package/artifacts/@openzeppelin/contracts/utils/StorageSlot.sol/StorageSlot.dbg.json +4 -0
  34. package/artifacts/@openzeppelin/contracts/utils/StorageSlot.sol/StorageSlot.json +10 -0
  35. package/artifacts/build-info/eb640ccbdf084d1d111d9ebf9250fdca.json +1 -0
  36. package/artifacts/contracts/ProxyAdmin2Step.sol/ProxyAdmin2Step.dbg.json +4 -0
  37. package/artifacts/contracts/ProxyAdmin2Step.sol/ProxyAdmin2Step.json +176 -0
  38. package/artifacts/contracts/TransparentUpgradeableProxy2Step.sol/TransparentUpgradeableProxy2Step.dbg.json +4 -0
  39. package/artifacts/contracts/TransparentUpgradeableProxy2Step.sol/TransparentUpgradeableProxy2Step.json +121 -0
  40. package/artifacts/contracts/interfaces/IProxyAdmin2Step.sol/IProxyAdmin2Step.dbg.json +4 -0
  41. package/artifacts/contracts/interfaces/IProxyAdmin2Step.sol/IProxyAdmin2Step.json +16 -0
  42. package/artifacts-flattened-contracts/contracts/ProxyAdmin2Step.flattened.sol +922 -0
  43. package/artifacts-flattened-contracts/contracts/TransparentUpgradeableProxy2Step.flattened.sol +1017 -0
  44. package/artifacts-tron/@openzeppelin/contracts/access/Ownable.sol/Ownable.dbg.json +4 -0
  45. package/artifacts-tron/@openzeppelin/contracts/access/Ownable.sol/Ownable.json +85 -0
  46. package/artifacts-tron/@openzeppelin/contracts/access/Ownable2Step.sol/Ownable2Step.dbg.json +4 -0
  47. package/artifacts-tron/@openzeppelin/contracts/access/Ownable2Step.sol/Ownable2Step.json +124 -0
  48. package/artifacts-tron/@openzeppelin/contracts/interfaces/IERC1967.sol/IERC1967.dbg.json +4 -0
  49. package/artifacts-tron/@openzeppelin/contracts/interfaces/IERC1967.sol/IERC1967.json +56 -0
  50. package/artifacts-tron/@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol/ERC1967Proxy.dbg.json +4 -0
  51. package/artifacts-tron/@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol/ERC1967Proxy.json +81 -0
  52. package/artifacts-tron/@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol/ERC1967Utils.dbg.json +4 -0
  53. package/artifacts-tron/@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol/ERC1967Utils.json +49 -0
  54. package/artifacts-tron/@openzeppelin/contracts/proxy/Proxy.sol/Proxy.dbg.json +4 -0
  55. package/artifacts-tron/@openzeppelin/contracts/proxy/Proxy.sol/Proxy.json +15 -0
  56. package/artifacts-tron/@openzeppelin/contracts/proxy/beacon/IBeacon.sol/IBeacon.dbg.json +4 -0
  57. package/artifacts-tron/@openzeppelin/contracts/proxy/beacon/IBeacon.sol/IBeacon.json +24 -0
  58. package/artifacts-tron/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol/ProxyAdmin.dbg.json +4 -0
  59. package/artifacts-tron/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol/ProxyAdmin.json +132 -0
  60. package/artifacts-tron/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/ITransparentUpgradeableProxy.dbg.json +4 -0
  61. package/artifacts-tron/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/ITransparentUpgradeableProxy.json +74 -0
  62. package/artifacts-tron/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy.dbg.json +4 -0
  63. package/artifacts-tron/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy.json +121 -0
  64. package/artifacts-tron/@openzeppelin/contracts/utils/Address.sol/Address.dbg.json +4 -0
  65. package/artifacts-tron/@openzeppelin/contracts/utils/Address.sol/Address.json +22 -0
  66. package/artifacts-tron/@openzeppelin/contracts/utils/Context.sol/Context.dbg.json +4 -0
  67. package/artifacts-tron/@openzeppelin/contracts/utils/Context.sol/Context.json +10 -0
  68. package/artifacts-tron/@openzeppelin/contracts/utils/Errors.sol/Errors.dbg.json +4 -0
  69. package/artifacts-tron/@openzeppelin/contracts/utils/Errors.sol/Errors.json +48 -0
  70. package/artifacts-tron/@openzeppelin/contracts/utils/LowLevelCall.sol/LowLevelCall.dbg.json +4 -0
  71. package/artifacts-tron/@openzeppelin/contracts/utils/LowLevelCall.sol/LowLevelCall.json +10 -0
  72. package/artifacts-tron/@openzeppelin/contracts/utils/StorageSlot.sol/StorageSlot.dbg.json +4 -0
  73. package/artifacts-tron/@openzeppelin/contracts/utils/StorageSlot.sol/StorageSlot.json +10 -0
  74. package/artifacts-tron/build-info/33e2b07450318007b249bcb542a1e222.json +1 -0
  75. package/artifacts-tron/contracts/ProxyAdmin2Step.sol/ProxyAdmin2Step.dbg.json +4 -0
  76. package/artifacts-tron/contracts/ProxyAdmin2Step.sol/ProxyAdmin2Step.json +176 -0
  77. package/artifacts-tron/contracts/TransparentUpgradeableProxy2Step.sol/TransparentUpgradeableProxy2Step.dbg.json +4 -0
  78. package/artifacts-tron/contracts/TransparentUpgradeableProxy2Step.sol/TransparentUpgradeableProxy2Step.json +121 -0
  79. package/artifacts-tron/contracts/interfaces/IProxyAdmin2Step.sol/IProxyAdmin2Step.dbg.json +4 -0
  80. package/artifacts-tron/contracts/interfaces/IProxyAdmin2Step.sol/IProxyAdmin2Step.json +16 -0
  81. package/artifacts-zk/@openzeppelin/contracts/access/Ownable.sol/Ownable.dbg.json +4 -0
  82. package/artifacts-zk/@openzeppelin/contracts/access/Ownable.sol/Ownable.json +86 -0
  83. package/artifacts-zk/@openzeppelin/contracts/access/Ownable2Step.sol/Ownable2Step.dbg.json +4 -0
  84. package/artifacts-zk/@openzeppelin/contracts/access/Ownable2Step.sol/Ownable2Step.json +125 -0
  85. package/artifacts-zk/@openzeppelin/contracts/interfaces/IERC1967.sol/IERC1967.dbg.json +4 -0
  86. package/artifacts-zk/@openzeppelin/contracts/interfaces/IERC1967.sol/IERC1967.json +57 -0
  87. package/artifacts-zk/@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol/ERC1967Proxy.dbg.json +4 -0
  88. package/artifacts-zk/@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol/ERC1967Proxy.json +82 -0
  89. package/artifacts-zk/@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol/ERC1967Utils.dbg.json +4 -0
  90. package/artifacts-zk/@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol/ERC1967Utils.json +50 -0
  91. package/artifacts-zk/@openzeppelin/contracts/proxy/Proxy.sol/Proxy.dbg.json +4 -0
  92. package/artifacts-zk/@openzeppelin/contracts/proxy/Proxy.sol/Proxy.json +16 -0
  93. package/artifacts-zk/@openzeppelin/contracts/proxy/beacon/IBeacon.sol/IBeacon.dbg.json +4 -0
  94. package/artifacts-zk/@openzeppelin/contracts/proxy/beacon/IBeacon.sol/IBeacon.json +25 -0
  95. package/artifacts-zk/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol/ProxyAdmin.dbg.json +4 -0
  96. package/artifacts-zk/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol/ProxyAdmin.json +133 -0
  97. package/artifacts-zk/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/ITransparentUpgradeableProxy.dbg.json +4 -0
  98. package/artifacts-zk/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/ITransparentUpgradeableProxy.json +75 -0
  99. package/artifacts-zk/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy.dbg.json +4 -0
  100. package/artifacts-zk/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy.json +124 -0
  101. package/artifacts-zk/@openzeppelin/contracts/utils/Address.sol/Address.dbg.json +4 -0
  102. package/artifacts-zk/@openzeppelin/contracts/utils/Address.sol/Address.json +23 -0
  103. package/artifacts-zk/@openzeppelin/contracts/utils/Context.sol/Context.dbg.json +4 -0
  104. package/artifacts-zk/@openzeppelin/contracts/utils/Context.sol/Context.json +11 -0
  105. package/artifacts-zk/@openzeppelin/contracts/utils/Errors.sol/Errors.dbg.json +4 -0
  106. package/artifacts-zk/@openzeppelin/contracts/utils/Errors.sol/Errors.json +49 -0
  107. package/artifacts-zk/@openzeppelin/contracts/utils/LowLevelCall.sol/LowLevelCall.dbg.json +4 -0
  108. package/artifacts-zk/@openzeppelin/contracts/utils/LowLevelCall.sol/LowLevelCall.json +11 -0
  109. package/artifacts-zk/@openzeppelin/contracts/utils/StorageSlot.sol/StorageSlot.dbg.json +4 -0
  110. package/artifacts-zk/@openzeppelin/contracts/utils/StorageSlot.sol/StorageSlot.json +11 -0
  111. package/artifacts-zk/build-info/9069f70cfc4c7329462d894dfdd2740c.json +1 -0
  112. package/artifacts-zk/contracts/ProxyAdmin2Step.sol/ProxyAdmin2Step.dbg.json +4 -0
  113. package/artifacts-zk/contracts/ProxyAdmin2Step.sol/ProxyAdmin2Step.json +177 -0
  114. package/artifacts-zk/contracts/TransparentUpgradeableProxy2Step.sol/TransparentUpgradeableProxy2Step.dbg.json +4 -0
  115. package/artifacts-zk/contracts/TransparentUpgradeableProxy2Step.sol/TransparentUpgradeableProxy2Step.json +124 -0
  116. package/artifacts-zk/contracts/interfaces/IProxyAdmin2Step.sol/IProxyAdmin2Step.dbg.json +4 -0
  117. package/artifacts-zk/contracts/interfaces/IProxyAdmin2Step.sol/IProxyAdmin2Step.json +17 -0
  118. package/contracts/ProxyAdmin2Step.sol +39 -0
  119. package/contracts/TransparentUpgradeableProxy2Step.sol +109 -0
  120. package/contracts/interfaces/IProxyAdmin2Step.sol +15 -0
  121. package/foundry.toml +23 -0
  122. package/hardhat.config.js +58 -0
  123. package/package.json +42 -0
  124. package/solhint.config.js +3 -0
  125. package/test/TransparentUpgradeableProxy2Step.t.sol +276 -0
  126. package/turbo-snapshot.lock.json +454 -0
@@ -0,0 +1,922 @@
1
+ pragma solidity ^0.8.22;
2
+
3
+
4
+ abstract contract Context {
5
+ function _msgSender() internal view virtual returns (address) {
6
+ return msg.sender;
7
+ }
8
+
9
+ function _msgData() internal view virtual returns (bytes calldata) {
10
+ return msg.data;
11
+ }
12
+
13
+ function _contextSuffixLength() internal view virtual returns (uint256) {
14
+ return 0;
15
+ }
16
+ }
17
+
18
+ abstract contract Ownable is Context {
19
+ address private _owner;
20
+
21
+ /**
22
+ * @dev The caller account is not authorized to perform an operation.
23
+ */
24
+ error OwnableUnauthorizedAccount(address account);
25
+
26
+ /**
27
+ * @dev The owner is not a valid owner account. (eg. `address(0)`)
28
+ */
29
+ error OwnableInvalidOwner(address owner);
30
+
31
+ event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
32
+
33
+ /**
34
+ * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
35
+ */
36
+ constructor(address initialOwner) {
37
+ if (initialOwner == address(0)) {
38
+ revert OwnableInvalidOwner(address(0));
39
+ }
40
+ _transferOwnership(initialOwner);
41
+ }
42
+
43
+ /**
44
+ * @dev Throws if called by any account other than the owner.
45
+ */
46
+ modifier onlyOwner() {
47
+ _checkOwner();
48
+ _;
49
+ }
50
+
51
+ /**
52
+ * @dev Returns the address of the current owner.
53
+ */
54
+ function owner() public view virtual returns (address) {
55
+ return _owner;
56
+ }
57
+
58
+ /**
59
+ * @dev Throws if the sender is not the owner.
60
+ */
61
+ function _checkOwner() internal view virtual {
62
+ if (owner() != _msgSender()) {
63
+ revert OwnableUnauthorizedAccount(_msgSender());
64
+ }
65
+ }
66
+
67
+ /**
68
+ * @dev Leaves the contract without owner. It will not be possible to call
69
+ * `onlyOwner` functions. Can only be called by the current owner.
70
+ *
71
+ * NOTE: Renouncing ownership will leave the contract without an owner,
72
+ * thereby disabling any functionality that is only available to the owner.
73
+ */
74
+ function renounceOwnership() public virtual onlyOwner {
75
+ _transferOwnership(address(0));
76
+ }
77
+
78
+ /**
79
+ * @dev Transfers ownership of the contract to a new account (`newOwner`).
80
+ * Can only be called by the current owner.
81
+ */
82
+ function transferOwnership(address newOwner) public virtual onlyOwner {
83
+ if (newOwner == address(0)) {
84
+ revert OwnableInvalidOwner(address(0));
85
+ }
86
+ _transferOwnership(newOwner);
87
+ }
88
+
89
+ /**
90
+ * @dev Transfers ownership of the contract to a new account (`newOwner`).
91
+ * Internal function without access restriction.
92
+ */
93
+ function _transferOwnership(address newOwner) internal virtual {
94
+ address oldOwner = _owner;
95
+ _owner = newOwner;
96
+ emit OwnershipTransferred(oldOwner, newOwner);
97
+ }
98
+ }
99
+
100
+ abstract contract Ownable2Step is Ownable {
101
+ address private _pendingOwner;
102
+
103
+ event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);
104
+
105
+ /**
106
+ * @dev Returns the address of the pending owner.
107
+ */
108
+ function pendingOwner() public view virtual returns (address) {
109
+ return _pendingOwner;
110
+ }
111
+
112
+ /**
113
+ * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
114
+ * Can only be called by the current owner.
115
+ *
116
+ * Setting `newOwner` to the zero address is allowed; this can be used to cancel an initiated ownership transfer.
117
+ */
118
+ function transferOwnership(address newOwner) public virtual override onlyOwner {
119
+ _pendingOwner = newOwner;
120
+ emit OwnershipTransferStarted(owner(), newOwner);
121
+ }
122
+
123
+ /**
124
+ * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
125
+ * Internal function without access restriction.
126
+ */
127
+ function _transferOwnership(address newOwner) internal virtual override {
128
+ delete _pendingOwner;
129
+ super._transferOwnership(newOwner);
130
+ }
131
+
132
+ /**
133
+ * @dev The new owner accepts the ownership transfer.
134
+ */
135
+ function acceptOwnership() public virtual {
136
+ address sender = _msgSender();
137
+ if (pendingOwner() != sender) {
138
+ revert OwnableUnauthorizedAccount(sender);
139
+ }
140
+ _transferOwnership(sender);
141
+ }
142
+ }
143
+
144
+ interface IBeacon {
145
+ /**
146
+ * @dev Must return an address that can be used as a delegate call target.
147
+ *
148
+ * {UpgradeableBeacon} will check that this address is a contract.
149
+ */
150
+ function implementation() external view returns (address);
151
+ }
152
+
153
+ interface IERC1967 {
154
+ /**
155
+ * @dev Emitted when the implementation is upgraded.
156
+ */
157
+ event Upgraded(address indexed implementation);
158
+
159
+ /**
160
+ * @dev Emitted when the admin account has changed.
161
+ */
162
+ event AdminChanged(address previousAdmin, address newAdmin);
163
+
164
+ /**
165
+ * @dev Emitted when the beacon is changed.
166
+ */
167
+ event BeaconUpgraded(address indexed beacon);
168
+ }
169
+
170
+ library Errors {
171
+ /**
172
+ * @dev The ETH balance of the account is not enough to perform the operation.
173
+ */
174
+ error InsufficientBalance(uint256 balance, uint256 needed);
175
+
176
+ /**
177
+ * @dev A call to an address target failed. The target may have reverted.
178
+ */
179
+ error FailedCall();
180
+
181
+ /**
182
+ * @dev The deployment failed.
183
+ */
184
+ error FailedDeployment();
185
+
186
+ /**
187
+ * @dev A necessary precompile is missing.
188
+ */
189
+ error MissingPrecompile(address);
190
+ }
191
+
192
+ library LowLevelCall {
193
+ /// @dev Performs a Solidity function call using a low level `call` and ignoring the return data.
194
+ function callNoReturn(address target, bytes memory data) internal returns (bool success) {
195
+ return callNoReturn(target, 0, data);
196
+ }
197
+
198
+ /// @dev Same as {callNoReturn-address-bytes}, but allows specifying the value to be sent in the call.
199
+ function callNoReturn(address target, uint256 value, bytes memory data) internal returns (bool success) {
200
+ assembly ("memory-safe") {
201
+ success := call(gas(), target, value, add(data, 0x20), mload(data), 0x00, 0x00)
202
+ }
203
+ }
204
+
205
+ /// @dev Performs a Solidity function call using a low level `call` and returns the first 64 bytes of the result
206
+ /// in the scratch space of memory. Useful for functions that return a tuple with two single-word values.
207
+ ///
208
+ /// WARNING: Do not assume that the results are zero if `success` is false. Memory can be already allocated
209
+ /// and this function doesn't zero it out.
210
+ function callReturn64Bytes(
211
+ address target,
212
+ bytes memory data
213
+ ) internal returns (bool success, bytes32 result1, bytes32 result2) {
214
+ return callReturn64Bytes(target, 0, data);
215
+ }
216
+
217
+ /// @dev Same as {callReturn64Bytes-address-bytes}, but allows specifying the value to be sent in the call.
218
+ function callReturn64Bytes(
219
+ address target,
220
+ uint256 value,
221
+ bytes memory data
222
+ ) internal returns (bool success, bytes32 result1, bytes32 result2) {
223
+ assembly ("memory-safe") {
224
+ success := call(gas(), target, value, add(data, 0x20), mload(data), 0x00, 0x40)
225
+ result1 := mload(0x00)
226
+ result2 := mload(0x20)
227
+ }
228
+ }
229
+
230
+ /// @dev Performs a Solidity function call using a low level `staticcall` and ignoring the return data.
231
+ function staticcallNoReturn(address target, bytes memory data) internal view returns (bool success) {
232
+ assembly ("memory-safe") {
233
+ success := staticcall(gas(), target, add(data, 0x20), mload(data), 0x00, 0x00)
234
+ }
235
+ }
236
+
237
+ /// @dev Performs a Solidity function call using a low level `staticcall` and returns the first 64 bytes of the result
238
+ /// in the scratch space of memory. Useful for functions that return a tuple with two single-word values.
239
+ ///
240
+ /// WARNING: Do not assume that the results are zero if `success` is false. Memory can be already allocated
241
+ /// and this function doesn't zero it out.
242
+ function staticcallReturn64Bytes(
243
+ address target,
244
+ bytes memory data
245
+ ) internal view returns (bool success, bytes32 result1, bytes32 result2) {
246
+ assembly ("memory-safe") {
247
+ success := staticcall(gas(), target, add(data, 0x20), mload(data), 0x00, 0x40)
248
+ result1 := mload(0x00)
249
+ result2 := mload(0x20)
250
+ }
251
+ }
252
+
253
+ /// @dev Performs a Solidity function call using a low level `delegatecall` and ignoring the return data.
254
+ function delegatecallNoReturn(address target, bytes memory data) internal returns (bool success) {
255
+ assembly ("memory-safe") {
256
+ success := delegatecall(gas(), target, add(data, 0x20), mload(data), 0x00, 0x00)
257
+ }
258
+ }
259
+
260
+ /// @dev Performs a Solidity function call using a low level `delegatecall` and returns the first 64 bytes of the result
261
+ /// in the scratch space of memory. Useful for functions that return a tuple with two single-word values.
262
+ ///
263
+ /// WARNING: Do not assume that the results are zero if `success` is false. Memory can be already allocated
264
+ /// and this function doesn't zero it out.
265
+ function delegatecallReturn64Bytes(
266
+ address target,
267
+ bytes memory data
268
+ ) internal returns (bool success, bytes32 result1, bytes32 result2) {
269
+ assembly ("memory-safe") {
270
+ success := delegatecall(gas(), target, add(data, 0x20), mload(data), 0x00, 0x40)
271
+ result1 := mload(0x00)
272
+ result2 := mload(0x20)
273
+ }
274
+ }
275
+
276
+ /// @dev Returns the size of the return data buffer.
277
+ function returnDataSize() internal pure returns (uint256 size) {
278
+ assembly ("memory-safe") {
279
+ size := returndatasize()
280
+ }
281
+ }
282
+
283
+ /// @dev Returns a buffer containing the return data from the last call.
284
+ function returnData() internal pure returns (bytes memory result) {
285
+ assembly ("memory-safe") {
286
+ result := mload(0x40)
287
+ mstore(result, returndatasize())
288
+ returndatacopy(add(result, 0x20), 0x00, returndatasize())
289
+ mstore(0x40, add(result, add(0x20, returndatasize())))
290
+ }
291
+ }
292
+
293
+ /// @dev Revert with the return data from the last call.
294
+ function bubbleRevert() internal pure {
295
+ assembly ("memory-safe") {
296
+ let fmp := mload(0x40)
297
+ returndatacopy(fmp, 0x00, returndatasize())
298
+ revert(fmp, returndatasize())
299
+ }
300
+ }
301
+
302
+ function bubbleRevert(bytes memory returndata) internal pure {
303
+ assembly ("memory-safe") {
304
+ revert(add(returndata, 0x20), mload(returndata))
305
+ }
306
+ }
307
+ }
308
+
309
+ library Address {
310
+ /**
311
+ * @dev There's no code at `target` (it is not a contract).
312
+ */
313
+ error AddressEmptyCode(address target);
314
+
315
+ /**
316
+ * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
317
+ * `recipient`, forwarding all available gas and reverting on errors.
318
+ *
319
+ * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
320
+ * of certain opcodes, possibly making contracts go over the 2300 gas limit
321
+ * imposed by `transfer`, making them unable to receive funds via
322
+ * `transfer`. {sendValue} removes this limitation.
323
+ *
324
+ * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
325
+ *
326
+ * IMPORTANT: because control is transferred to `recipient`, care must be
327
+ * taken to not create reentrancy vulnerabilities. Consider using
328
+ * {ReentrancyGuard} or the
329
+ * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
330
+ */
331
+ function sendValue(address payable recipient, uint256 amount) internal {
332
+ if (address(this).balance < amount) {
333
+ revert Errors.InsufficientBalance(address(this).balance, amount);
334
+ }
335
+ if (LowLevelCall.callNoReturn(recipient, amount, "")) {
336
+ // call successful, nothing to do
337
+ return;
338
+ } else if (LowLevelCall.returnDataSize() > 0) {
339
+ LowLevelCall.bubbleRevert();
340
+ } else {
341
+ revert Errors.FailedCall();
342
+ }
343
+ }
344
+
345
+ /**
346
+ * @dev Performs a Solidity function call using a low level `call`. A
347
+ * plain `call` is an unsafe replacement for a function call: use this
348
+ * function instead.
349
+ *
350
+ * If `target` reverts with a revert reason or custom error, it is bubbled
351
+ * up by this function (like regular Solidity function calls). However, if
352
+ * the call reverted with no returned reason, this function reverts with a
353
+ * {Errors.FailedCall} error.
354
+ *
355
+ * Returns the raw returned data. To convert to the expected return value,
356
+ * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
357
+ *
358
+ * Requirements:
359
+ *
360
+ * - `target` must be a contract.
361
+ * - calling `target` with `data` must not revert.
362
+ */
363
+ function functionCall(address target, bytes memory data) internal returns (bytes memory) {
364
+ return functionCallWithValue(target, data, 0);
365
+ }
366
+
367
+ /**
368
+ * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
369
+ * but also transferring `value` wei to `target`.
370
+ *
371
+ * Requirements:
372
+ *
373
+ * - the calling contract must have an ETH balance of at least `value`.
374
+ * - the called Solidity function must be `payable`.
375
+ */
376
+ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
377
+ if (address(this).balance < value) {
378
+ revert Errors.InsufficientBalance(address(this).balance, value);
379
+ }
380
+ bool success = LowLevelCall.callNoReturn(target, value, data);
381
+ if (success && (LowLevelCall.returnDataSize() > 0 || target.code.length > 0)) {
382
+ return LowLevelCall.returnData();
383
+ } else if (success) {
384
+ revert AddressEmptyCode(target);
385
+ } else if (LowLevelCall.returnDataSize() > 0) {
386
+ LowLevelCall.bubbleRevert();
387
+ } else {
388
+ revert Errors.FailedCall();
389
+ }
390
+ }
391
+
392
+ /**
393
+ * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
394
+ * but performing a static call.
395
+ */
396
+ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
397
+ bool success = LowLevelCall.staticcallNoReturn(target, data);
398
+ if (success && (LowLevelCall.returnDataSize() > 0 || target.code.length > 0)) {
399
+ return LowLevelCall.returnData();
400
+ } else if (success) {
401
+ revert AddressEmptyCode(target);
402
+ } else if (LowLevelCall.returnDataSize() > 0) {
403
+ LowLevelCall.bubbleRevert();
404
+ } else {
405
+ revert Errors.FailedCall();
406
+ }
407
+ }
408
+
409
+ /**
410
+ * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
411
+ * but performing a delegate call.
412
+ */
413
+ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
414
+ bool success = LowLevelCall.delegatecallNoReturn(target, data);
415
+ if (success && (LowLevelCall.returnDataSize() > 0 || target.code.length > 0)) {
416
+ return LowLevelCall.returnData();
417
+ } else if (success) {
418
+ revert AddressEmptyCode(target);
419
+ } else if (LowLevelCall.returnDataSize() > 0) {
420
+ LowLevelCall.bubbleRevert();
421
+ } else {
422
+ revert Errors.FailedCall();
423
+ }
424
+ }
425
+
426
+ /**
427
+ * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
428
+ * was not a contract or bubbling up the revert reason (falling back to {Errors.FailedCall}) in case
429
+ * of an unsuccessful call.
430
+ *
431
+ * NOTE: This function is DEPRECATED and may be removed in the next major release.
432
+ */
433
+ function verifyCallResultFromTarget(
434
+ address target,
435
+ bool success,
436
+ bytes memory returndata
437
+ ) internal view returns (bytes memory) {
438
+ // only check if target is a contract if the call was successful and the return data is empty
439
+ // otherwise we already know that it was a contract
440
+ if (success && (returndata.length > 0 || target.code.length > 0)) {
441
+ return returndata;
442
+ } else if (success) {
443
+ revert AddressEmptyCode(target);
444
+ } else if (returndata.length > 0) {
445
+ LowLevelCall.bubbleRevert(returndata);
446
+ } else {
447
+ revert Errors.FailedCall();
448
+ }
449
+ }
450
+
451
+ /**
452
+ * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
453
+ * revert reason or with a default {Errors.FailedCall} error.
454
+ */
455
+ function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
456
+ if (success) {
457
+ return returndata;
458
+ } else if (returndata.length > 0) {
459
+ LowLevelCall.bubbleRevert(returndata);
460
+ } else {
461
+ revert Errors.FailedCall();
462
+ }
463
+ }
464
+ }
465
+
466
+ library StorageSlot {
467
+ struct AddressSlot {
468
+ address value;
469
+ }
470
+
471
+ struct BooleanSlot {
472
+ bool value;
473
+ }
474
+
475
+ struct Bytes32Slot {
476
+ bytes32 value;
477
+ }
478
+
479
+ struct Uint256Slot {
480
+ uint256 value;
481
+ }
482
+
483
+ struct Int256Slot {
484
+ int256 value;
485
+ }
486
+
487
+ struct StringSlot {
488
+ string value;
489
+ }
490
+
491
+ struct BytesSlot {
492
+ bytes value;
493
+ }
494
+
495
+ /**
496
+ * @dev Returns an `AddressSlot` with member `value` located at `slot`.
497
+ */
498
+ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
499
+ assembly ("memory-safe") {
500
+ r.slot := slot
501
+ }
502
+ }
503
+
504
+ /**
505
+ * @dev Returns a `BooleanSlot` with member `value` located at `slot`.
506
+ */
507
+ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
508
+ assembly ("memory-safe") {
509
+ r.slot := slot
510
+ }
511
+ }
512
+
513
+ /**
514
+ * @dev Returns a `Bytes32Slot` with member `value` located at `slot`.
515
+ */
516
+ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
517
+ assembly ("memory-safe") {
518
+ r.slot := slot
519
+ }
520
+ }
521
+
522
+ /**
523
+ * @dev Returns a `Uint256Slot` with member `value` located at `slot`.
524
+ */
525
+ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
526
+ assembly ("memory-safe") {
527
+ r.slot := slot
528
+ }
529
+ }
530
+
531
+ /**
532
+ * @dev Returns a `Int256Slot` with member `value` located at `slot`.
533
+ */
534
+ function getInt256Slot(bytes32 slot) internal pure returns (Int256Slot storage r) {
535
+ assembly ("memory-safe") {
536
+ r.slot := slot
537
+ }
538
+ }
539
+
540
+ /**
541
+ * @dev Returns a `StringSlot` with member `value` located at `slot`.
542
+ */
543
+ function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
544
+ assembly ("memory-safe") {
545
+ r.slot := slot
546
+ }
547
+ }
548
+
549
+ /**
550
+ * @dev Returns an `StringSlot` representation of the string storage pointer `store`.
551
+ */
552
+ function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
553
+ assembly ("memory-safe") {
554
+ r.slot := store.slot
555
+ }
556
+ }
557
+
558
+ /**
559
+ * @dev Returns a `BytesSlot` with member `value` located at `slot`.
560
+ */
561
+ function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
562
+ assembly ("memory-safe") {
563
+ r.slot := slot
564
+ }
565
+ }
566
+
567
+ /**
568
+ * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
569
+ */
570
+ function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
571
+ assembly ("memory-safe") {
572
+ r.slot := store.slot
573
+ }
574
+ }
575
+ }
576
+
577
+ library ERC1967Utils {
578
+ /**
579
+ * @dev Storage slot with the address of the current implementation.
580
+ * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1.
581
+ */
582
+ // solhint-disable-next-line private-vars-leading-underscore
583
+ bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
584
+
585
+ /**
586
+ * @dev The `implementation` of the proxy is invalid.
587
+ */
588
+ error ERC1967InvalidImplementation(address implementation);
589
+
590
+ /**
591
+ * @dev The `admin` of the proxy is invalid.
592
+ */
593
+ error ERC1967InvalidAdmin(address admin);
594
+
595
+ /**
596
+ * @dev The `beacon` of the proxy is invalid.
597
+ */
598
+ error ERC1967InvalidBeacon(address beacon);
599
+
600
+ /**
601
+ * @dev An upgrade function sees `msg.value > 0` that may be lost.
602
+ */
603
+ error ERC1967NonPayable();
604
+
605
+ /**
606
+ * @dev Returns the current implementation address.
607
+ */
608
+ function getImplementation() internal view returns (address) {
609
+ return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value;
610
+ }
611
+
612
+ /**
613
+ * @dev Stores a new address in the ERC-1967 implementation slot.
614
+ */
615
+ function _setImplementation(address newImplementation) private {
616
+ if (newImplementation.code.length == 0) {
617
+ revert ERC1967InvalidImplementation(newImplementation);
618
+ }
619
+ StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation;
620
+ }
621
+
622
+ /**
623
+ * @dev Performs implementation upgrade with additional setup call if data is nonempty.
624
+ * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
625
+ * to avoid stuck value in the contract.
626
+ *
627
+ * Emits an {IERC1967-Upgraded} event.
628
+ */
629
+ function upgradeToAndCall(address newImplementation, bytes memory data) internal {
630
+ _setImplementation(newImplementation);
631
+ emit IERC1967.Upgraded(newImplementation);
632
+
633
+ if (data.length > 0) {
634
+ Address.functionDelegateCall(newImplementation, data);
635
+ } else {
636
+ _checkNonPayable();
637
+ }
638
+ }
639
+
640
+ /**
641
+ * @dev Storage slot with the admin of the contract.
642
+ * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1.
643
+ */
644
+ // solhint-disable-next-line private-vars-leading-underscore
645
+ bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
646
+
647
+ /**
648
+ * @dev Returns the current admin.
649
+ *
650
+ * TIP: To get this value clients can read directly from the storage slot shown below (specified by ERC-1967) using
651
+ * the https://ethereum.org/developers/docs/apis/json-rpc/#eth_getstorageat[`eth_getStorageAt`] RPC call.
652
+ * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
653
+ */
654
+ function getAdmin() internal view returns (address) {
655
+ return StorageSlot.getAddressSlot(ADMIN_SLOT).value;
656
+ }
657
+
658
+ /**
659
+ * @dev Stores a new address in the ERC-1967 admin slot.
660
+ */
661
+ function _setAdmin(address newAdmin) private {
662
+ if (newAdmin == address(0)) {
663
+ revert ERC1967InvalidAdmin(address(0));
664
+ }
665
+ StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin;
666
+ }
667
+
668
+ /**
669
+ * @dev Changes the admin of the proxy.
670
+ *
671
+ * Emits an {IERC1967-AdminChanged} event.
672
+ */
673
+ function changeAdmin(address newAdmin) internal {
674
+ emit IERC1967.AdminChanged(getAdmin(), newAdmin);
675
+ _setAdmin(newAdmin);
676
+ }
677
+
678
+ /**
679
+ * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
680
+ * This is the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1.
681
+ */
682
+ // solhint-disable-next-line private-vars-leading-underscore
683
+ bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
684
+
685
+ /**
686
+ * @dev Returns the current beacon.
687
+ */
688
+ function getBeacon() internal view returns (address) {
689
+ return StorageSlot.getAddressSlot(BEACON_SLOT).value;
690
+ }
691
+
692
+ /**
693
+ * @dev Stores a new beacon in the ERC-1967 beacon slot.
694
+ */
695
+ function _setBeacon(address newBeacon) private {
696
+ if (newBeacon.code.length == 0) {
697
+ revert ERC1967InvalidBeacon(newBeacon);
698
+ }
699
+
700
+ StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon;
701
+
702
+ address beaconImplementation = IBeacon(newBeacon).implementation();
703
+ if (beaconImplementation.code.length == 0) {
704
+ revert ERC1967InvalidImplementation(beaconImplementation);
705
+ }
706
+ }
707
+
708
+ /**
709
+ * @dev Change the beacon and trigger a setup call if data is nonempty.
710
+ * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
711
+ * to avoid stuck value in the contract.
712
+ *
713
+ * Emits an {IERC1967-BeaconUpgraded} event.
714
+ *
715
+ * CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since
716
+ * it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for
717
+ * efficiency.
718
+ */
719
+ function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal {
720
+ _setBeacon(newBeacon);
721
+ emit IERC1967.BeaconUpgraded(newBeacon);
722
+
723
+ if (data.length > 0) {
724
+ Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
725
+ } else {
726
+ _checkNonPayable();
727
+ }
728
+ }
729
+
730
+ /**
731
+ * @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract
732
+ * if an upgrade doesn't perform an initialization call.
733
+ */
734
+ function _checkNonPayable() private {
735
+ if (msg.value > 0) {
736
+ revert ERC1967NonPayable();
737
+ }
738
+ }
739
+ }
740
+
741
+ abstract contract Proxy {
742
+ /**
743
+ * @dev Delegates the current call to `implementation`.
744
+ *
745
+ * This function does not return to its internal call site, it will return directly to the external caller.
746
+ */
747
+ function _delegate(address implementation) internal virtual {
748
+ assembly {
749
+ // Copy msg.data. We take full control of memory in this inline assembly
750
+ // block because it will not return to Solidity code. We overwrite the
751
+ // Solidity scratch pad at memory position 0.
752
+ calldatacopy(0x00, 0x00, calldatasize())
753
+
754
+ // Call the implementation.
755
+ // out and outsize are 0 because we don't know the size yet.
756
+ let result := delegatecall(gas(), implementation, 0x00, calldatasize(), 0x00, 0x00)
757
+
758
+ // Copy the returned data.
759
+ returndatacopy(0x00, 0x00, returndatasize())
760
+
761
+ switch result
762
+ // delegatecall returns 0 on error.
763
+ case 0 {
764
+ revert(0x00, returndatasize())
765
+ }
766
+ default {
767
+ return(0x00, returndatasize())
768
+ }
769
+ }
770
+ }
771
+
772
+ /**
773
+ * @dev This is a virtual function that should be overridden so it returns the address to which the fallback
774
+ * function and {_fallback} should delegate.
775
+ */
776
+ function _implementation() internal view virtual returns (address);
777
+
778
+ /**
779
+ * @dev Delegates the current call to the address returned by `_implementation()`.
780
+ *
781
+ * This function does not return to its internal call site, it will return directly to the external caller.
782
+ */
783
+ function _fallback() internal virtual {
784
+ _delegate(_implementation());
785
+ }
786
+
787
+ /**
788
+ * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
789
+ * function in the contract matches the call data.
790
+ */
791
+ fallback() external payable virtual {
792
+ _fallback();
793
+ }
794
+ }
795
+
796
+ contract ERC1967Proxy is Proxy {
797
+ /**
798
+ * @dev The proxy is left uninitialized.
799
+ */
800
+ error ERC1967ProxyUninitialized();
801
+
802
+ /**
803
+ * @dev Initializes the upgradeable proxy with an initial implementation specified by `implementation`.
804
+ *
805
+ * Provided `_data` is passed in a delegate call to `implementation`. This will typically be an encoded function
806
+ * call, and allows initializing the storage of the proxy like a Solidity constructor. By default construction
807
+ * will fail if `_data` is empty. This behavior can be overridden using a custom {_unsafeAllowUninitialized} that
808
+ * returns true. In that case, empty `_data` is ignored and no delegate call to the implementation is performed
809
+ * during construction.
810
+ *
811
+ * Requirements:
812
+ *
813
+ * - If `data` is empty, `msg.value` must be zero.
814
+ */
815
+ constructor(address implementation, bytes memory _data) payable {
816
+ if (!_unsafeAllowUninitialized() && _data.length == 0) {
817
+ revert ERC1967ProxyUninitialized();
818
+ }
819
+ ERC1967Utils.upgradeToAndCall(implementation, _data);
820
+ }
821
+
822
+ /**
823
+ * @dev Returns the current implementation address.
824
+ *
825
+ * TIP: To get this value clients can read directly from the storage slot shown below (specified by ERC-1967) using
826
+ * the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
827
+ * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`
828
+ */
829
+ function _implementation() internal view virtual override returns (address) {
830
+ return ERC1967Utils.getImplementation();
831
+ }
832
+
833
+ /**
834
+ * @dev Returns whether the proxy can be left uninitialized.
835
+ *
836
+ * NOTE: Override this function to allow the proxy to be left uninitialized.
837
+ * Consider uninitialized proxies might be susceptible to man-in-the-middle threats
838
+ * where the proxy is replaced with a malicious one.
839
+ */
840
+ function _unsafeAllowUninitialized() internal pure virtual returns (bool) {
841
+ return false;
842
+ }
843
+ }
844
+
845
+ contract ProxyAdmin is Ownable {
846
+ /**
847
+ * @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgrade(address,address)`
848
+ * and `upgradeAndCall(address,address,bytes)` are present, and `upgrade` must be used if no function should be called,
849
+ * while `upgradeAndCall` will invoke the `receive` function if the third argument is the empty byte string.
850
+ * If the getter returns `"5.0.0"`, only `upgradeAndCall(address,address,bytes)` is present, and the third argument must
851
+ * be the empty byte string if no function should be called, making it impossible to invoke the `receive` function
852
+ * during an upgrade.
853
+ */
854
+ string public constant UPGRADE_INTERFACE_VERSION = "5.0.0";
855
+
856
+ /**
857
+ * @dev Sets the initial owner who can perform upgrades.
858
+ */
859
+ constructor(address initialOwner) Ownable(initialOwner) {}
860
+
861
+ /**
862
+ * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation.
863
+ * See {TransparentUpgradeableProxy-_dispatchUpgradeToAndCall}.
864
+ *
865
+ * Requirements:
866
+ *
867
+ * - This contract must be the admin of `proxy`.
868
+ * - If `data` is empty, `msg.value` must be zero.
869
+ */
870
+ function upgradeAndCall(
871
+ ITransparentUpgradeableProxy proxy,
872
+ address implementation,
873
+ bytes memory data
874
+ ) public payable virtual onlyOwner {
875
+ proxy.upgradeToAndCall{value: msg.value}(implementation, data);
876
+ }
877
+ }
878
+
879
+ interface ITransparentUpgradeableProxy is IERC1967 {
880
+ /// @dev See {UUPSUpgradeable-upgradeToAndCall}
881
+ function upgradeToAndCall(address newImplementation, bytes calldata data) external payable;
882
+ }
883
+
884
+ interface IProxyAdmin2Step {
885
+ /**
886
+ * @notice Thrown when trying to renounce ownership.
887
+ */
888
+ error CannotRenounceOwnership();
889
+ }
890
+
891
+ // SPDX-License-Identifier: MIT
892
+ /**
893
+ * @title ProxyAdmin2Step
894
+ * @author LayerZero Labs (tinom.eth)
895
+ * @custom:version 1.0.0
896
+ * @notice OZ's `ProxyAdmin` with `Ownable2Step` ownership transfers and disallowed renouncement.
897
+ */
898
+ contract ProxyAdmin2Step is IProxyAdmin2Step, ProxyAdmin, Ownable2Step {
899
+ constructor(address _initialOwner) ProxyAdmin(_initialOwner) {}
900
+
901
+ /**
902
+ * @inheritdoc Ownable2Step
903
+ */
904
+ function transferOwnership(address _newOwner) public virtual override(Ownable, Ownable2Step) {
905
+ Ownable2Step.transferOwnership(_newOwner);
906
+ }
907
+
908
+ /**
909
+ * @inheritdoc Ownable2Step
910
+ */
911
+ function _transferOwnership(address _newOwner) internal virtual override(Ownable, Ownable2Step) {
912
+ Ownable2Step._transferOwnership(_newOwner);
913
+ }
914
+
915
+ /**
916
+ * @dev Override to prevent renouncing ownership.
917
+ * @inheritdoc Ownable
918
+ */
919
+ function renounceOwnership() public virtual override {
920
+ revert CannotRenounceOwnership();
921
+ }
922
+ }