-
Notifications
You must be signed in to change notification settings - Fork 376
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ Tidy 7702 code, regen docs (#1358)
- Loading branch information
1 parent
fe8ca07
commit 9298d09
Showing
5 changed files
with
167 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
# LibEIP7702 | ||
|
||
Library for EIP7702 operations. | ||
|
||
|
||
|
||
|
||
|
||
|
||
<!-- customintro:start --><!-- customintro:end --> | ||
|
||
## Custom Errors | ||
|
||
### ProxyQueryFailed() | ||
|
||
```solidity | ||
error ProxyQueryFailed() | ||
``` | ||
|
||
The proxy query has failed. | ||
|
||
### ChangeProxyAdminFailed() | ||
|
||
```solidity | ||
error ChangeProxyAdminFailed() | ||
``` | ||
|
||
Failed to change the proxy admin. | ||
|
||
### UpgradeProxyFailed() | ||
|
||
```solidity | ||
error UpgradeProxyFailed() | ||
``` | ||
|
||
Failed to upgrade the proxy. | ||
|
||
## Constants | ||
|
||
### ERC1967_IMPLEMENTATION_SLOT | ||
|
||
```solidity | ||
bytes32 internal constant ERC1967_IMPLEMENTATION_SLOT = | ||
0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc | ||
``` | ||
|
||
The ERC-1967 storage slot for the implementation in the proxy. | ||
`uint256(keccak256("eip1967.proxy.implementation")) - 1`. | ||
|
||
### EIP7702_PROXY_DELEGATION_INITIALIZATION_REQUEST_SLOT | ||
|
||
```solidity | ||
bytes32 internal constant | ||
EIP7702_PROXY_DELEGATION_INITIALIZATION_REQUEST_SLOT = | ||
0x94e11c6e41e7fb92cb8bb65e13fdfbd4eba8b831292a1a220f7915c78c7c078f | ||
``` | ||
|
||
The transient storage slot for requesting the proxy to initialize the implementation. | ||
`uint256(keccak256("eip7702.proxy.delegation.initialization.request")) - 1`. | ||
While we would love to use a smaller constant, this slot is used in both the proxy | ||
and the delegation, so we shall just use bytes32 in case we want to standardize this. | ||
|
||
## Authority Operations | ||
|
||
### delegation(address) | ||
|
||
```solidity | ||
function delegation(address account) | ||
internal | ||
view | ||
returns (address result) | ||
``` | ||
|
||
Returns the delegation of the account. | ||
If the account is not an EIP7702 authority, the `delegation` will be `address(0)`. | ||
|
||
## Proxy Operations | ||
|
||
### proxyImplementation(address) | ||
|
||
```solidity | ||
function proxyImplementation(address proxy) | ||
internal | ||
view | ||
returns (address result) | ||
``` | ||
|
||
Returns the implementation of the proxy. | ||
Assumes that the proxy is a proper EIP7702Proxy, if it exists. | ||
|
||
### proxyAdmin(address) | ||
|
||
```solidity | ||
function proxyAdmin(address proxy) internal view returns (address result) | ||
``` | ||
|
||
Returns the admin of the proxy. | ||
Assumes that the proxy is a proper EIP7702Proxy, if it exists. | ||
|
||
### changeProxyAdmin(address,address) | ||
|
||
```solidity | ||
function changeProxyAdmin(address proxy, address newAdmin) internal | ||
``` | ||
|
||
Changes the admin on the proxy. The caller must be the admin. | ||
Assumes that the proxy is a proper EIP7702Proxy, if it exists. | ||
|
||
### upgradeProxy(address,address) | ||
|
||
```solidity | ||
function upgradeProxy(address proxy, address newImplementation) internal | ||
``` | ||
|
||
Changes the implementation on the proxy. The caller must be the admin. | ||
Assumes that the proxy is a proper EIP7702Proxy, if it exists. | ||
|
||
## Proxy Delegation Operations | ||
|
||
### upgradeProxyDelegation(address) | ||
|
||
```solidity | ||
function upgradeProxyDelegation(address newImplementation) internal | ||
``` | ||
|
||
Upgrades the implementation. | ||
The new implementation will NOT be active until the next UserOp or transaction. | ||
To "auto-upgrade" to the latest implementation on the proxy, pass in `address(0)` to reset | ||
the implementation slot. This causes the proxy to use the latest default implementation, | ||
which may be optionally reinitialized via `requestProxyDelegationInitialization()`. | ||
This function is intended to be used on the authority of an EIP7702Proxy delegation. | ||
The most intended usage pattern is to wrap this in an access-gated admin function. | ||
|
||
### requestProxyDelegationInitialization() | ||
|
||
```solidity | ||
function requestProxyDelegationInitialization() internal | ||
``` | ||
|
||
Requests the implementation to be initialized to the latest implementation on the proxy. | ||
This function is intended to be used on the authority of an EIP7702Proxy delegation. | ||
The most intended usage pattern is to place it at the end of an `execute` function. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters