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

added aux code indexer interface, fixed more typos #28

Merged
merged 1 commit into from
Nov 20, 2024
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
5 changes: 5 additions & 0 deletions .changeset/nasty-points-wait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@peeramid-labs/eds": patch
---

added aux file for codeIndex interface in more loose pragma to be more reusable as library
14 changes: 14 additions & 0 deletions src/ICodeIndexDep.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: CC0-1.0
pragma solidity >=0.8.0 <0.9.0;

// This file is exactly same as ./ICodeIndexer.sol\
// With exception for more loose pragma version
// Updating the CodeIndex pragma directly would cause changing the deployed bytecode for ERC7744
interface ICodeIndex {
event Indexed(address indexed container, bytes32 indexed codeHash);
error alreadyExists(bytes32 id, address source);

function register(address container) external;

function get(bytes32 id) external view returns (address);
}
6 changes: 3 additions & 3 deletions src/abstracts/Distributor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ abstract contract Distributor is IDistributor, CodeIndexer, ERC165 {
EnumerableSet.Bytes32Set private distributionsSet;
mapping(address instance => uint256 instanceId) private instanceIds;
mapping(uint256 instance => bytes32 distributorsId) public distributionOf;
mapping(bytes32 distributorsId => DistributionComponent distirbution) public distributionComponents;
mapping(bytes32 distributorsId => DistributionComponent distribution) public distributionComponents;
mapping(bytes32 distributorsId => LibSemver.VersionRequirement VersionRequirement) public versionRequirements;
mapping(uint256 instanceId => LibSemver.Version instanceVersion) public instanceVersions;

Expand Down Expand Up @@ -114,7 +114,7 @@ abstract contract Distributor is IDistributor, CodeIndexer, ERC165 {
LibSemver.VersionRequirement memory versionRequirement = versionRequirements[distributorsId];

// External initializer is provided, delegatecall to it
// Countrary, if no initializer is provided, the distribution is expected to be self-initializing
// Contrary, if no initializer is provided, the distribution is expected to be self-initializing
bool externallyInitialized = distributionComponent.initializer == address(0);
bytes4 selector = IInitializer.initialize.selector;
bytes memory instantiationArgs = externallyInitialized ? args : bytes("");
Expand All @@ -130,7 +130,7 @@ abstract contract Distributor is IDistributor, CodeIndexer, ERC165 {
instantiationArgs
);
// Unversioned distributions are considered to be at version 0, and are not expected to change
// This might change in the future, as it could make sence to inherit `distributionVersion` from the distribution
// This might change in the future, as it could make sense to inherit `distributionVersion` from the distribution
// Yet for ease of runtime validation and to avoid potential issues, we keep it at 0
instanceVersions[numInstances] = LibSemver.parse(0);
} else {
Expand Down
16 changes: 8 additions & 8 deletions src/libraries/LibSemver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity >=0.8.0 <0.9.0;
import "@openzeppelin/contracts/utils/Strings.sol";
library LibSemver {
error versionMissmatch(string message);
error versionMismatch(string message);
struct Version {
uint64 major;
uint64 minor;
Expand Down Expand Up @@ -47,32 +47,32 @@ library LibSemver {
}

function require_exact(Version memory _version1, Version memory _version2) internal pure {
if (toUint256(_version1) != toUint256(_version2)) revert versionMissmatch("Version mismatch");
if (toUint256(_version1) != toUint256(_version2)) revert versionMismatch("Version mismatch");
}

function require_major(Version memory _version1, Version memory _version2) internal pure {
if (_version1.major != _version2.major) revert versionMissmatch("Major version mismatch");
if (_version1.major != _version2.major) revert versionMismatch("Major version mismatch");
}

function require_major_minor(Version memory _version1, Version memory _version2) internal pure {
if (_version1.major != _version2.major || _version1.minor != _version2.minor)
revert versionMissmatch("Major and minor version mismatch");
revert versionMismatch("Major and minor version mismatch");
}

function require_greater_equal(Version memory _version1, Version memory _version2) internal pure {
if (toUint256(_version1) < toUint256(_version2)) revert versionMissmatch("Version is not greater or equal");
if (toUint256(_version1) < toUint256(_version2)) revert versionMismatch("Version is not greater or equal");
}

function require_greater(Version memory _version1, Version memory _version2) internal pure {
if (toUint256(_version1) <= toUint256(_version2)) revert versionMissmatch("Version is not greater");
if (toUint256(_version1) <= toUint256(_version2)) revert versionMismatch("Version is not greater");
}

function require_lesser_equal(Version memory _version1, Version memory _version2) internal pure {
if (toUint256(_version1) > toUint256(_version2)) revert versionMissmatch("Version is not lesser or equal");
if (toUint256(_version1) > toUint256(_version2)) revert versionMismatch("Version is not lesser or equal");
}

function require_lesser(Version memory _version1, Version memory _version2) internal pure {
if (toUint256(_version1) >= toUint256(_version2)) revert versionMissmatch("Version is not lesser");
if (toUint256(_version1) >= toUint256(_version2)) revert versionMismatch("Version is not lesser");
}

function areEqual(Version memory _version1, Version memory _version2) internal pure returns (bool) {
Expand Down
Loading