Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update EIP-6551: Update eip-6551.md #7159

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions EIPS/eip-6551.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,16 @@ Non-fungible token contracts that do not implement an `ownerOf` method, such as
```solidity
pragma solidity ^0.8.13;

import "openzeppelin-contracts/utils/introspection/IERC165.sol";
import "openzeppelin-contracts/token/ERC721/IERC721.sol";
import "openzeppelin-contracts/interfaces/IERC1271.sol";
import "openzeppelin-contracts/utils/cryptography/SignatureChecker.sol";
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/interfaces/IERC1271.sol";
import "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol";
import "sstore2/utils/Bytecode.sol";
import "./interfaces/IERC6551Account.sol";

contract ExampleERC6551Account is IERC165, IERC1271, IERC6551Account {
receive() external payable {}
uint256 private _nonce;

function executeCall(
address to,
Expand All @@ -267,6 +269,7 @@ contract ExampleERC6551Account is IERC165, IERC1271, IERC6551Account {
revert(add(result, 32), mload(result))
}
}
_nonce++;
}

function token()
Expand All @@ -278,7 +281,7 @@ contract ExampleERC6551Account is IERC165, IERC1271, IERC6551Account {
uint256 tokenId
)
{
uint256 length = address(this).code.length
uint256 length = address(this).code.length;
return
abi.decode(
Bytecode.codeAt(address(this), length - 0x60, length),
Expand Down Expand Up @@ -316,6 +319,10 @@ contract ExampleERC6551Account is IERC165, IERC1271, IERC6551Account {

return "";
}

function nonce() external view returns (uint256) {
return _nonce;
}
}
```

Expand All @@ -325,6 +332,7 @@ contract ExampleERC6551Account is IERC165, IERC1271, IERC6551Account {
pragma solidity ^0.8.13;

import "openzeppelin-contracts/utils/Create2.sol";
import "./interfaces/IERC6551Registry.sol";

contract ERC6551Registry is IERC6551Registry {
error InitializationFailed();
Expand All @@ -337,7 +345,7 @@ contract ERC6551Registry is IERC6551Registry {
uint256 salt,
bytes calldata initData
) external returns (address) {
bytes memory code = _creationCode(implementation, chainId, tokenContract, tokenId, salt)
bytes memory code = _creationCode(implementation, chainId, tokenContract, tokenId, salt);

address _account = Create2.computeAddress(
bytes32(salt),
Expand Down