-
Notifications
You must be signed in to change notification settings - Fork 183
Closed
Description
From https://wizard.openzeppelin.com/#account , leave the defaults selected, then add "Modules" so that the options appear as shown:
This results in the code:
Solidity code
// SPDX-License-Identifier: MIT
// Compatible with OpenZeppelin Contracts ^5.4.0
pragma solidity ^0.8.27;
import {AbstractSigner} from "@openzeppelin/contracts/utils/cryptography/signers/AbstractSigner.sol";
import {Account} from "@openzeppelin/contracts/account/Account.sol";
import {AccountERC7579} from "@openzeppelin/contracts/account/extensions/draft-AccountERC7579.sol";
import {EIP712} from "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
import {ERC1155Holder} from "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol";
import {ERC721Holder} from "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol";
import {ERC7739} from "@openzeppelin/contracts/utils/cryptography/signers/draft-ERC7739.sol";
import {PackedUserOperation} from "@openzeppelin/contracts/interfaces/draft-IERC4337.sol";
import {SignerECDSA} from "@openzeppelin/contracts/utils/cryptography/signers/SignerECDSA.sol";
contract MyAccount is Account, EIP712, ERC7739, AccountERC7579, SignerECDSA, ERC721Holder, ERC1155Holder {
constructor(address signer) EIP712("MyAccount", "1") SignerECDSA(signer) {}
function isValidSignature(bytes32 hash, bytes calldata signature)
public
view
override(AccountERC7579, ERC7739)
returns (bytes4)
{
// ERC-7739 can return the ERC-1271 magic value, 0xffffffff (invalid) or 0x77390001 (detection).
// If the returned value is 0xffffffff, fallback to ERC-7579 validation.
bytes4 erc7739magic = ERC7739.isValidSignature(hash, signature);
return erc7739magic == bytes4(0xffffffff) ? AccountERC7579.isValidSignature(hash, signature) : erc7739magic;
}
// The following functions are overrides required by Solidity.
function _validateUserOp(PackedUserOperation calldata userOp, bytes32 userOpHash)
internal
override(Account, AccountERC7579)
returns (uint256)
{
return super._validateUserOp(userOp, userOpHash);
}
// IMPORTANT: Make sure SignerECDSA is most derived than AccountERC7579
// in the inheritance chain (i.e. contract ... is AccountERC7579, ..., SignerECDSA)
// to ensure the correct order of function resolution.
// AccountERC7579 returns false for _rawSignatureValidation
function _rawSignatureValidation(bytes32 hash, bytes calldata signature)
internal
view
override(SignerECDSA, AbstractSigner, AccountERC7579)
returns (bool)
{
return super._rawSignatureValidation(hash, signature);
}
}The contract does not appear in Remix. From the browser console when on Remix, the following error is seen:
InvalidCharacterError: Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.
at decodePercentEscapedBase64 (workspace.ts:281:25)
at _callee18$ (workspace.ts:307:19)
at tryCatch (regeneratorRuntime.js:45:16)
at Generator.<anonymous> (regeneratorRuntime.js:133:17)
at Generator.next (regeneratorRuntime.js:74:21)
at asyncGeneratorStep (asyncToGenerator.js:3:15)
at _next (asyncToGenerator.js:17:9)
at asyncToGenerator.js:22:7
at new Promise (<anonymous>)
at asyncToGenerator.js:14:12
We should investigate whether the above URL is encoded correctly in Wizard, and/or whether it is being decoded correctly from Remix.
Metadata
Metadata
Assignees
Labels
No labels
