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

Add proxy call to 6492 reference implementation #878

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
26 changes: 25 additions & 1 deletion ERCS/erc-6492.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,33 @@ interface IERC1271Wallet {
function isValidSignature(bytes32 hash, bytes calldata signature) external view returns (bytes4 magicValue);
}

error ShouldCallFromValidator();

contract FactoryCaller {
address public immutable universalSigValidator;

constructor(){
universalSigValidator = msg.sender;
}

function proxyCall(
address _factory,
bytes calldata _initCallData
) external returns (bool success, bytes memory err) {
if (msg.sender != universalSigValidator) {
revert ShouldCallFromValidator();
}

return _factory.call(_initCallData);
}
}

error ERC1271Revert(bytes error);
error ERC6492DeployFailed(bytes error);

contract UniversalSigValidator {
FactoryCaller immutable public factoryCaller = new FactoryCaller();

bytes32 private constant ERC6492_DETECTION_SUFFIX = 0x6492649264926492649264926492649264926492649264926492649264926492;
bytes4 private constant ERC1271_SUCCESS = 0x1626ba7e;

Expand All @@ -128,7 +151,8 @@ contract UniversalSigValidator {
(create2Factory, factoryCalldata, sigToValidate) = abi.decode(_signature[0:_signature.length-32], (address, bytes, bytes));

if (contractCodeLen == 0 || tryPrepare) {
(bool success, bytes memory err) = create2Factory.call(factoryCalldata);
// Proxy call using factory called to stop arbitrary calls from UniversalSigValidator
(bool success, bytes memory err) = factoryCaller.proxyCall(create2Factory, factoryCalldata);
if (!success) revert ERC6492DeployFailed(err);
}
} else {
Expand Down
Loading