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

chore: merging upstream methods from layer #20

Merged
merged 1 commit into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
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
12 changes: 11 additions & 1 deletion contracts/src/ILayerServiceManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,14 @@
pragma solidity ^0.8.9;

interface ILayerServiceManager {
}
// ------------------------------------------------------------------------
// Custom Errors
// ------------------------------------------------------------------------
error InvalidSignature();

/**
* @param data The arbitrary data that was signed.
* @param signature The signature of the data.
*/
function validate(bytes calldata data, bytes calldata signature) external view;
}
16 changes: 16 additions & 0 deletions contracts/src/LayerServiceManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -142,5 +142,21 @@ contract LayerServiceManager is ECDSAServiceManagerBase, ILayerServiceManager {
// selector: selector
// });
}
function validate(bytes calldata data, bytes calldata signature) external view
{
bytes32 message = keccak256(data);
bytes32 ethSignedMessageHash = ECDSAUpgradeable.toEthSignedMessageHash(message);
bytes4 magicValue = IERC1271Upgradeable.isValidSignature.selector;

// If the registry returns the magicValue, signature is considered valid
if( magicValue !=
ECDSAStakeRegistry(stakeRegistry).isValidSignature(
ethSignedMessageHash,
signature
)
) {
revert ILayerServiceManager.InvalidSignature();
}
}

}