Skip to content
Open
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ gas-report.txt
# IDE
.idea
.vscode
.claude
CLAUDE.md
Comment on lines +35 to +36
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to mention them? I'm using it too, but just a question if we can add them, same for different repos

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potentially there could be some sensitive data in these files, I don't want to check that at every commit so I prefer not to include them.


# Environment variables
.env
Expand Down
2 changes: 1 addition & 1 deletion contracts/IdentityUtilities.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.27;
pragma solidity ^0.8.27;

import { IClaimIssuer } from "./interface/IClaimIssuer.sol";
import { IIdentity } from "./interface/IIdentity.sol";
Expand Down
29 changes: 9 additions & 20 deletions contracts/factory/IdFactory.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.27;

import { ICreateX } from "@createx/ICreateX.sol";
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";

import { IERC734 } from "../interface/IERC734.sol";
Expand All @@ -15,6 +16,8 @@ contract IdFactory is IIdFactory, Ownable {
// address of the _implementationAuthority contract making the link to the implementation contract
address public immutable implementationAuthority;

address public immutable deployer;

mapping(address => bool) private _tokenFactories;

// as it is not possible to deploy 2 times the same contract address, this mapping allows us to check which
Expand All @@ -34,9 +37,12 @@ contract IdFactory is IIdFactory, Ownable {
mapping(address => address) private _tokenAddress;

// setting
constructor(address implementationAuthorityAddress) Ownable(msg.sender) {
constructor(address implementationAuthorityAddress, address deployerAddress) Ownable(msg.sender) {
require(implementationAuthorityAddress != address(0), Errors.ZeroAddress());
require(deployerAddress != address(0), Errors.ZeroAddress());

implementationAuthority = implementationAuthorityAddress;
deployer = deployerAddress;
}

/**
Expand Down Expand Up @@ -208,30 +214,13 @@ contract IdFactory is IIdFactory, Ownable {
return _tokenFactories[_factory];
}

// deploy function with create2 opcode call
// returns the address of the contract created
function _deploy(string memory salt, bytes memory bytecode) private returns (address) {
bytes32 saltBytes = bytes32(keccak256(abi.encodePacked(salt)));
address addr;
// solhint-disable-next-line no-inline-assembly
assembly {
let encoded_data := add(0x20, bytecode) // load initialization code.
let encoded_size := mload(bytecode) // load init code's length.
addr := create2(0, encoded_data, encoded_size, saltBytes)
if iszero(extcodesize(addr)) {
revert(0, 0)
}
}
emit Deployed(addr);
return addr;
}

// function used to deploy an identity using CREATE2
function _deployIdentity(string memory _salt, address _wallet) private returns (address) {
bytes memory _code = type(IdentityProxy).creationCode;
bytes memory _constructData = abi.encode(implementationAuthority, _wallet);
bytes memory bytecode = abi.encodePacked(_code, _constructData);
return _deploy(_salt, bytecode);

return ICreateX(deployer).deployCreate3(keccak256(abi.encodePacked(_salt)), bytecode);
}

}
2 changes: 1 addition & 1 deletion contracts/interface/IIdentityUtilities.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.27;
pragma solidity ^0.8.27;

/// @title IIdentityUtilities
/// @notice Interface for a schema registry that maps topic IDs to structured metadata schemas
Expand Down
8 changes: 8 additions & 0 deletions foundry.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"lib/forge-std": {
"tag": {
"name": "v1.14.0",
"rev": "1801b0541f4fda118a10798fd3486bb7051c5dd6"
}
}
}
5 changes: 4 additions & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ test = "test"
script = "scripts"
libs = ["dependencies"]

solc_version = "0.8.27"
solc_version = "0.8.30"
optimizer = true
optimizer_runs = 200
evm_version = "shanghai"
Expand All @@ -18,6 +18,8 @@ bracket_spacing = true
[profile.default.lint]
lint_on_build = true

fs_permissions = [{ access = "read", path = "out" }]

[rpc_endpoints]
baseSepolia = "https://base-sepolia.g.alchemy.com/v2/${ALCHEMY_KEY}"
base = "https://base-mainnet.g.alchemy.com/v2/${ALCHEMY_KEY}"
Expand All @@ -29,4 +31,5 @@ remappings_regenerate = false
forge-std = { version = "v1.14.0", git = "https://github.com/foundry-rs/forge-std.git", tag = "v1.14.0" }
"@openzeppelin-contracts" = "5.2.0"
"@openzeppelin-contracts-upgradeable" = "4.9.6"
createx = { version = "main", git = "https://github.com/TokenySolutions/createx", branch = "main" }
solady = "0.1.15"
Loading