Skip to content

Commit dd75ad8

Browse files
🔀 Merge branch 'develop' into feature/BT-1447-global-identity-registry-id-factory
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2 parents ba2332f + ac0c249 commit dd75ad8

6 files changed

Lines changed: 833 additions & 10520 deletions

File tree

‎contracts/interface/IImplementationAuthority.sol‎

Lines changed: 0 additions & 22 deletions
This file was deleted.

‎contracts/libraries/Errors.sol‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,6 @@ library Errors {
8585

8686
/* ----- IdentityProxy ----- */
8787

88-
/// @notice The initialization failed.
89-
error InitializationFailed();
90-
9188
/* ----- ClaimIssuer ----- */
9289

9390
/// @notice The claim already exists.
Lines changed: 6 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,14 @@
11
// SPDX-License-Identifier: GPL-3.0
2-
32
pragma solidity ^0.8.27;
43

5-
import { IImplementationAuthority } from "../interface/IImplementationAuthority.sol";
6-
import { Errors } from "../libraries/Errors.sol";
7-
8-
contract IdentityProxy {
9-
10-
/**
11-
* @dev constructor of the proxy Identity contract
12-
* @param _implementationAuthority the implementation Authority contract address
13-
* @param initialManagementKey the management key at deployment
14-
* the proxy is going to use the logic deployed on the implementation contract
15-
* deployed at an address listed in the ImplementationAuthority contract
16-
*/
17-
constructor(address _implementationAuthority, address initialManagementKey) {
18-
require(_implementationAuthority != address(0), Errors.ZeroAddress());
19-
require(initialManagementKey != address(0), Errors.ZeroAddress());
20-
21-
// solhint-disable-next-line no-inline-assembly
22-
assembly {
23-
sstore(0x821f3e4d3d679f19eacc940c87acf846ea6eae24a63058ea750304437a62aafc, _implementationAuthority)
24-
}
25-
26-
address logic = IImplementationAuthority(_implementationAuthority).getImplementation();
27-
28-
// solhint-disable-next-line avoid-low-level-calls
29-
(bool success,) = logic.delegatecall(abi.encodeWithSignature("initialize(address)", initialManagementKey));
30-
require(success, Errors.InitializationFailed());
31-
}
4+
import { BeaconProxy } from "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol";
325

33-
/**
34-
* @dev fallback proxy function used for any transaction call that is made using
35-
* the Identity contract ABI and called on the proxy contract
36-
* The proxy will update its local storage depending on the behaviour requested
37-
* by the implementation contract given by the Implementation Authority
38-
*/
39-
// solhint-disable-next-line no-complex-fallback
40-
fallback() external payable {
41-
address logic = IImplementationAuthority(implementationAuthority()).getImplementation();
6+
import { Identity } from "../Identity.sol";
427

43-
// solhint-disable-next-line no-inline-assembly
44-
assembly {
45-
calldatacopy(0x0, 0x0, calldatasize())
46-
let success := delegatecall(sub(gas(), 10000), logic, 0x0, calldatasize(), 0, 0)
47-
let retSz := returndatasize()
48-
returndatacopy(0, 0, retSz)
49-
switch success
50-
case 0 {
51-
revert(0, retSz)
52-
}
53-
default {
54-
return(0, retSz)
55-
}
56-
}
57-
}
8+
contract IdentityProxy is BeaconProxy {
589

59-
function implementationAuthority() public view returns (address) {
60-
address implemAuth;
61-
// solhint-disable-next-line no-inline-assembly
62-
assembly {
63-
implemAuth := sload(0x821f3e4d3d679f19eacc940c87acf846ea6eae24a63058ea750304437a62aafc)
64-
}
65-
return implemAuth;
66-
}
10+
constructor(address _implementationAuthority, address _initialManagementKey)
11+
BeaconProxy(_implementationAuthority, abi.encodeCall(Identity.initialize, (_initialManagementKey)))
12+
{ }
6713

6814
}
Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,10 @@
11
// SPDX-License-Identifier: GPL-3.0
2-
32
pragma solidity ^0.8.27;
43

5-
import { IImplementationAuthority } from "../interface/IImplementationAuthority.sol";
6-
import { Errors } from "../libraries/Errors.sol";
7-
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
8-
9-
contract ImplementationAuthority is IImplementationAuthority, Ownable {
10-
11-
// the address of implementation of ONCHAINID
12-
address internal _implementation;
13-
14-
constructor(address implementation) Ownable(msg.sender) {
15-
require(implementation != address(0), Errors.ZeroAddress());
16-
_implementation = implementation;
17-
emit UpdatedImplementation(implementation);
18-
}
4+
import { UpgradeableBeacon } from "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol";
195

20-
/**
21-
* @dev See {IImplementationAuthority-updateImplementation}.
22-
*/
23-
function updateImplementation(address _newImplementation) external override onlyOwner {
24-
require(_newImplementation != address(0), Errors.ZeroAddress());
25-
_implementation = _newImplementation;
26-
emit UpdatedImplementation(_newImplementation);
27-
}
6+
contract ImplementationAuthority is UpgradeableBeacon {
287

29-
/**
30-
* @dev See {IImplementationAuthority-getImplementation}.
31-
*/
32-
function getImplementation() external view override returns (address) {
33-
return _implementation;
34-
}
8+
constructor(address implementation) UpgradeableBeacon(implementation, msg.sender) { }
359

3610
}

0 commit comments

Comments
 (0)