@t-rex-network/onchainid 0.0.0-stage → 3.0.0-beta2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. package/LICENSE.md +674 -0
  2. package/NOTICE.md +66 -0
  3. package/README.md +177 -2
  4. package/contracts/Identity.sol +235 -0
  5. package/contracts/IdentityUtilities.sol +269 -0
  6. package/contracts/KeyManager.sol +193 -0
  7. package/contracts/SmartAccount.sol +222 -0
  8. package/contracts/factory/IIdentityFactory.sol +325 -0
  9. package/contracts/factory/IdentityFactory.sol +818 -0
  10. package/contracts/interface/IClaimIssuer.sol +105 -0
  11. package/contracts/interface/IERC734.sol +69 -0
  12. package/contracts/interface/IERC735.sol +149 -0
  13. package/contracts/interface/IIdentity.sol +63 -0
  14. package/contracts/interface/IIdentityUtilities.sol +135 -0
  15. package/contracts/interface/IKeyExecutor.sol +84 -0
  16. package/contracts/libraries/Errors.sol +407 -0
  17. package/contracts/libraries/FormatResolver.sol +74 -0
  18. package/contracts/libraries/Hashing.sol +35 -0
  19. package/contracts/libraries/IdentityTypes.sol +53 -0
  20. package/contracts/libraries/KeyPurposes.sol +49 -0
  21. package/contracts/libraries/KeyTypes.sol +46 -0
  22. package/contracts/modules/claims/EASClaimIssuer.sol +348 -0
  23. package/contracts/modules/executors/KeyApprovalModule.sol +313 -0
  24. package/contracts/modules/executors/RecoveryModule.sol +88 -0
  25. package/contracts/modules/validators/ERC734Validator.sol +1000 -0
  26. package/contracts/modules/validators/ERC7579Validator.sol +74 -0
  27. package/contracts/proxy/IdentityUtilitiesProxy.sol +36 -0
  28. package/contracts/reputation/IReputationRegistry.sol +117 -0
  29. package/contracts/reputation/ReputationRegistry.sol +155 -0
  30. package/contracts/storage/Structs.sol +176 -0
  31. package/contracts/vendor/eas/IEAS.sol +36 -0
  32. package/contracts/vendor/utils/SafeCalldataBatch.sol +61 -0
  33. package/out/AbstractSigner.sol/AbstractSigner.json +1 -0
  34. package/out/AccessControlUpgradeable.sol/AccessControlUpgradeable.json +1 -0
  35. package/out/AccessManaged.sol/AccessManaged.json +1 -0
  36. package/out/AccessManager.sol/AccessManager.json +1 -0
  37. package/out/Account.sol/Account.json +1 -0
  38. package/out/AddClaimByTrustedIssuer.t.sol/AddClaimAsTrustedIssuerTest.json +1 -0
  39. package/out/Address.sol/Address.json +1 -0
  40. package/out/Arrays.sol/Arrays.json +1 -0
  41. package/out/AuthorityUtils.sol/AuthorityUtils.json +1 -0
  42. package/out/Base.sol/CommonBase.json +1 -0
  43. package/out/Base.sol/ScriptBase.json +1 -0
  44. package/out/Base.sol/TestBase.json +1 -0
  45. package/out/Base64.sol/Base64.json +1 -0
  46. package/out/BatchDecodeParity.t.sol/BatchDecodeParityTest.json +1 -0
  47. package/out/BeaconProxy.sol/BeaconProxy.json +1 -0
  48. package/out/Bytes.sol/Bytes.json +1 -0
  49. package/out/Calldata.sol/Calldata.json +1 -0
  50. package/out/ClaimSignatureDefinition.t.sol/ClaimSignatureDefinitionTest.json +1 -0
  51. package/out/ClaimSignatureDefinition.t.sol/NoERC1271Delegate.json +1 -0
  52. package/out/ClaimSignatureDefinition.t.sol/PickyERC1271Delegate.json +1 -0
  53. package/out/ClaimSignerHelper.sol/ClaimSignerHelper.json +1 -0
  54. package/out/ClaimTo.t.sol/ClaimToTest.json +1 -0
  55. package/out/Claims.t.sol/ClaimsTest.json +1 -0
  56. package/out/Claims.t.sol/ExternalIssuer.json +1 -0
  57. package/out/Comparators.sol/Comparators.json +1 -0
  58. package/out/Constants.sol/Constants.json +1 -0
  59. package/out/Context.sol/Context.json +1 -0
  60. package/out/ContextUpgradeable.sol/ContextUpgradeable.json +1 -0
  61. package/out/Create2.sol/Create2.json +1 -0
  62. package/out/Create3.sol/Create3.json +1 -0
  63. package/out/DeployOnchainID.s.sol/DeployOnchainID.json +1 -0
  64. package/out/EASClaimIssuer.sol/EASClaimIssuer.json +1 -0
  65. package/out/EASClaimIssuer.t.sol/EASClaimIssuerTest.json +1 -0
  66. package/out/EASClaimIssuer.t.sol/VmContractHelper29562166e1daff82a9ba4e08c324c14e885cfef135c42b5774ced18642e5fa19.json +1 -0
  67. package/out/EASTypes.sol/IEASTest.json +1 -0
  68. package/out/EASTypes.sol/ISchemaRegistryTest.json +1 -0
  69. package/out/ECDSA.sol/ECDSA.json +1 -0
  70. package/out/EIP712.sol/EIP712.json +1 -0
  71. package/out/ERC165.sol/ERC165.json +1 -0
  72. package/out/ERC165Upgradeable.sol/ERC165Upgradeable.json +1 -0
  73. package/out/ERC1967Proxy.sol/ERC1967Proxy.json +1 -0
  74. package/out/ERC1967Utils.sol/ERC1967Utils.json +1 -0
  75. package/out/ERC4337Utils.sol/ERC4337Utils.json +1 -0
  76. package/out/ERC4337Utils.sol/IEntryPointExtra.json +1 -0
  77. package/out/ERC734Validator.sol/ERC734Validator.json +1 -0
  78. package/out/ERC734Validator.t.sol/ERC734ValidatorTest.json +1 -0
  79. package/out/ERC734Validator.t.sol/PocCounter.json +1 -0
  80. package/out/ERC734Validator.t.sol/VmContractHelper7beb488c9b6c5f9f79178a8ce1e9ea8b7d447a9f1b366d4a3784214e9066b776.json +1 -0
  81. package/out/ERC7579DelayedExecutor.sol/ERC7579DelayedExecutor.json +1 -0
  82. package/out/ERC7579Executor.sol/ERC7579Executor.json +1 -0
  83. package/out/ERC7579Multisig.sol/ERC7579Multisig.json +1 -0
  84. package/out/ERC7579MultisigWeighted.sol/ERC7579MultisigWeighted.json +1 -0
  85. package/out/ERC7579SocialRecoveryExecutor.sol/ERC7579SocialRecoveryExecutor.json +1 -0
  86. package/out/ERC7579Validator.sol/ERC7579Validator.json +1 -0
  87. package/out/ERC7786Recipient.sol/ERC7786Recipient.json +1 -0
  88. package/out/ERC7913WebAuthnVerifier.sol/ERC7913WebAuthnVerifier.json +1 -0
  89. package/out/EnumerableSet.sol/EnumerableSet.json +1 -0
  90. package/out/Errors.sol/Errors.json +1 -0
  91. package/out/Executions.t.sol/ETHReceiver.json +1 -0
  92. package/out/Executions.t.sol/ExecutionsTest.json +1 -0
  93. package/out/Executions.t.sol/RevertingReceiver.json +1 -0
  94. package/out/FormatResolver.sol/FormatResolver.json +1 -0
  95. package/out/Hashes.sol/Hashes.json +1 -0
  96. package/out/IAccessControl.sol/IAccessControl.json +1 -0
  97. package/out/IAccessManaged.sol/IAccessManaged.json +1 -0
  98. package/out/IAccessManager.sol/IAccessManager.json +1 -0
  99. package/out/IAuthority.sol/IAuthority.json +1 -0
  100. package/out/IBeacon.sol/IBeacon.json +1 -0
  101. package/out/IClaimIssuer.sol/IClaimIssuer.json +1 -0
  102. package/out/IEAS.sol/IEAS.json +1 -0
  103. package/out/IERC1271.sol/IERC1271.json +1 -0
  104. package/out/IERC165.sol/IERC165.json +1 -0
  105. package/out/IERC1967.sol/IERC1967.json +1 -0
  106. package/out/IERC4337.sol/IAccount.json +1 -0
  107. package/out/IERC4337.sol/IAccountExecute.json +1 -0
  108. package/out/IERC4337.sol/IAggregator.json +1 -0
  109. package/out/IERC4337.sol/IEntryPoint.json +1 -0
  110. package/out/IERC4337.sol/IEntryPointNonces.json +1 -0
  111. package/out/IERC4337.sol/IEntryPointStake.json +1 -0
  112. package/out/IERC4337.sol/IPaymaster.json +1 -0
  113. package/out/IERC5267.sol/IERC5267.json +1 -0
  114. package/out/IERC734.sol/IERC734.json +1 -0
  115. package/out/IERC734Surface.t.sol/IERC734SurfaceTest.json +1 -0
  116. package/out/IERC735.sol/IERC735.json +1 -0
  117. package/out/IERC7913.sol/IERC7913SignatureVerifier.json +1 -0
  118. package/out/IIdentity.sol/IIdentity.json +1 -0
  119. package/out/IIdentityFactory.sol/IIdentityFactory.json +1 -0
  120. package/out/IIdentityUtilities.sol/IIdentityUtilities.json +1 -0
  121. package/out/IKeyExecutor.sol/IKeyExecutor.json +1 -0
  122. package/out/IMulticall3.sol/IMulticall3.json +1 -0
  123. package/out/IReputationRegistry.sol/IReputationRegistry.json +1 -0
  124. package/out/Identity.sol/Identity.json +1 -0
  125. package/out/IdentityFactory.sol/IdentityFactory.json +1 -0
  126. package/out/IdentityFactory.t.sol/IdentityFactoryTest.json +1 -0
  127. package/out/IdentityFactory.t.sol/VmContractHelper28a7b3ffc37fea8b5c41ecc8f253eb5ab470e21bb0401440d9a55fcb4f8afe5c.json +1 -0
  128. package/out/IdentityHelper.sol/IdentityHelper.json +1 -0
  129. package/out/IdentityHelper.sol/VmContractHelper78387a8fc41a64804f1f0fc2cbba310bbca11e4f057b06dfa169d4c103c08be5.json +1 -0
  130. package/out/IdentityTypes.sol/IdentityTypes.json +1 -0
  131. package/out/IdentityUtilities.sol/IdentityUtilities.json +1 -0
  132. package/out/IdentityUtilities.t.sol/IdentityUtilitiesTest.json +1 -0
  133. package/out/IdentityUtilities.t.sol/VmContractHelper7ed074704942d210565581d7e79e91a1d3425a5a7e758acb90866c42420e726c.json +1 -0
  134. package/out/IdentityUtilitiesProxy.sol/IdentityUtilitiesProxy.json +1 -0
  135. package/out/Init.t.sol/InitTest.json +1 -0
  136. package/out/Init.t.sol/VmContractHelper95bc81f417f4a3acb58eafba49b7834c5e65588c78654308ee428eb7d9276cce.json +1 -0
  137. package/out/Initializable.sol/Initializable.json +1 -0
  138. package/out/InteroperableAddressEncoding.t.sol/InteroperableAddressEncodingTest.json +1 -0
  139. package/out/KeyApprovalModule.sol/IIdentityAccount.json +1 -0
  140. package/out/KeyApprovalModule.sol/KeyApprovalModule.json +1 -0
  141. package/out/KeyApprovalModuleFactoryGuard.t.sol/KeyApprovalModuleFactoryGuardTest.json +1 -0
  142. package/out/KeyManager.sol/KeyManager.json +1 -0
  143. package/out/KeyPurposes.sol/KeyPurposes.json +1 -0
  144. package/out/KeyTypes.sol/KeyTypes.json +1 -0
  145. package/out/Keys.t.sol/KeysTest.json +1 -0
  146. package/out/LowLevelCall.sol/LowLevelCall.json +1 -0
  147. package/out/Math.sol/Math.json +1 -0
  148. package/out/MessageHashUtils.sol/MessageHashUtils.json +1 -0
  149. package/out/MockERC1271Signer.sol/MockERC1271Signer.json +1 -0
  150. package/out/MockERC1271Wallet.sol/MockERC1271Wallet.json +1 -0
  151. package/out/MockERC7786Gateway.sol/MockERC7786Gateway.json +1 -0
  152. package/out/MockERC7913PermissiveVerifier.sol/MockERC7913PermissiveVerifier.json +1 -0
  153. package/out/MockLyingERC734Getter.sol/MockLyingERC734Getter.json +1 -0
  154. package/out/MockStockECDSAValidator.sol/MockStockECDSAValidator.json +1 -0
  155. package/out/Multicall.sol/Multicall.json +1 -0
  156. package/out/Multisig.sol/Multisig.json +1 -0
  157. package/out/Nonces.sol/Nonces.json +1 -0
  158. package/out/OnchainIDSetup.sol/OnchainIDSetup.json +1 -0
  159. package/out/Ownable.sol/Ownable.json +1 -0
  160. package/out/P256.sol/P256.json +1 -0
  161. package/out/Packing.sol/Packing.json +1 -0
  162. package/out/Panic.sol/Panic.json +1 -0
  163. package/out/PrivilegedReentryGuard.t.sol/PocCounter.json +1 -0
  164. package/out/PrivilegedReentryGuard.t.sol/PrivilegedReentryGuardTest.json +1 -0
  165. package/out/Proxy.sol/Proxy.json +1 -0
  166. package/out/Proxy.t.sol/ProxyTest.json +1 -0
  167. package/out/Proxy.t.sol/VmContractHelper20ec29ce959b555228240226871c123d935ae49f617ce49540ee53c85f9f8cd4.json +1 -0
  168. package/out/ProxyPattern.t.sol/ProxyPatternTest.json +1 -0
  169. package/out/RecoveryModule.sol/RecoveryModule.json +1 -0
  170. package/out/RecoveryModule.t.sol/RecoveryModuleTest.json +1 -0
  171. package/out/RecoveryModule.t.sol/VmContractHelper84563bc19cefad0d2824def84f4cab79093d389b1866eff467a2908e14dd8421.json +1 -0
  172. package/out/ReputationRegistry.sol/ReputationRegistry.json +1 -0
  173. package/out/ReputationRegistry.t.sol/FakeIdentity.json +1 -0
  174. package/out/ReputationRegistry.t.sol/ReputationRegistryTest.json +1 -0
  175. package/out/ReputationRegistry.t.sol/VmContractHelper4353cedc5e63171396a0756138ec48ebba489252c7f4fef50b08f9e2c0989ec9.json +1 -0
  176. package/out/RevertingIdentity.sol/RevertingIdentity.json +1 -0
  177. package/out/SafeCalldataBatch.sol/SafeCalldataBatch.json +1 -0
  178. package/out/SafeCast.sol/SafeCast.json +1 -0
  179. package/out/Script.sol/Script.json +1 -0
  180. package/out/ShortStrings.sol/ShortStrings.json +1 -0
  181. package/out/SignatureChecker.sol/SignatureChecker.json +1 -0
  182. package/out/SignedMath.sol/SignedMath.json +1 -0
  183. package/out/SlotDerivation.sol/SlotDerivation.json +1 -0
  184. package/out/SmartAccount.sol/SmartAccount.json +1 -0
  185. package/out/SmartAccount.t.sol/AlwaysApprovePolicy.json +1 -0
  186. package/out/SmartAccount.t.sol/Counter.json +1 -0
  187. package/out/SmartAccount.t.sol/IAddKeyWithData.json +1 -0
  188. package/out/SmartAccount.t.sol/ReentrantUninstaller.json +1 -0
  189. package/out/SmartAccount.t.sol/SmartAccountTest.json +1 -0
  190. package/out/SmartAccount.t.sol/TestExecutor.json +1 -0
  191. package/out/StdAssertions.sol/StdAssertions.json +1 -0
  192. package/out/StdChains.sol/StdChains.json +1 -0
  193. package/out/StdCheats.sol/StdCheats.json +1 -0
  194. package/out/StdCheats.sol/StdCheatsSafe.json +1 -0
  195. package/out/StdConstants.sol/StdConstants.json +1 -0
  196. package/out/StdError.sol/stdError.json +1 -0
  197. package/out/StdInvariant.sol/StdInvariant.json +1 -0
  198. package/out/StdJson.sol/stdJson.json +1 -0
  199. package/out/StdMath.sol/stdMath.json +1 -0
  200. package/out/StdStorage.sol/stdStorage.json +1 -0
  201. package/out/StdStorage.sol/stdStorageSafe.json +1 -0
  202. package/out/StdStyle.sol/StdStyle.json +1 -0
  203. package/out/StdToml.sol/stdToml.json +1 -0
  204. package/out/StdUtils.sol/StdUtils.json +1 -0
  205. package/out/StorageSlot.sol/StorageSlot.json +1 -0
  206. package/out/Strings.sol/Strings.json +1 -0
  207. package/out/Structs.sol/Structs.json +1 -0
  208. package/out/Test.sol/Test.json +1 -0
  209. package/out/TestIdentityUtilities.sol/TestIdentityUtilities.json +1 -0
  210. package/out/Time.sol/Time.json +1 -0
  211. package/out/TokenOid.t.sol/TokenOidTest.json +1 -0
  212. package/out/UUPSUpgradeable.sol/UUPSUpgradeable.json +1 -0
  213. package/out/UnlockedIdentity.sol/UnlockedIdentity.json +1 -0
  214. package/out/UpgradeableBeacon.sol/UpgradeableBeacon.json +1 -0
  215. package/out/VersionUpgrade.t.sol/VersionUpgradeTest.json +1 -0
  216. package/out/Vm.sol/Vm.json +1 -0
  217. package/out/Vm.sol/VmSafe.json +1 -0
  218. package/out/WebAuthn.sol/WebAuthn.json +1 -0
  219. package/out/WebAuthn.t.sol/WebAuthnTest.json +1 -0
  220. package/out/build-info/1056f64abc9637ee.json +1 -0
  221. package/out/console.sol/console.json +1 -0
  222. package/out/draft-AccountERC7579Upgradeable.sol/AccountERC7579Upgradeable.json +1 -0
  223. package/out/draft-ERC7579Utils.sol/ERC7579Utils.json +1 -0
  224. package/out/draft-IERC1822.sol/IERC1822Proxiable.json +1 -0
  225. package/out/draft-IERC7579.sol/IERC7579AccountConfig.json +1 -0
  226. package/out/draft-IERC7579.sol/IERC7579Execution.json +1 -0
  227. package/out/draft-IERC7579.sol/IERC7579Hook.json +1 -0
  228. package/out/draft-IERC7579.sol/IERC7579Module.json +1 -0
  229. package/out/draft-IERC7579.sol/IERC7579ModuleConfig.json +1 -0
  230. package/out/draft-IERC7579.sol/IERC7579Validator.json +1 -0
  231. package/out/draft-IERC7786.sol/IERC7786GatewaySource.json +1 -0
  232. package/out/draft-IERC7786.sol/IERC7786Recipient.json +1 -0
  233. package/out/draft-InteroperableAddress.sol/InteroperableAddress.json +1 -0
  234. package/out/safeconsole.sol/safeconsole.json +1 -0
  235. package/out/src/Test.sol/Test.json +1 -0
  236. package/out/utils/Errors.sol/Errors.json +1 -0
  237. package/package.json +75 -4
@@ -0,0 +1,222 @@
1
+ // SPDX-License-Identifier: GPL-3.0
2
+ //
3
+ // ONCHAINID Smart Contracts
4
+ // Digital identities for the T-REX ecosystem.
5
+ //
6
+ // Copyright (C) 2026 Digital Asset Operational Services ISAC Ltd. ("T-REX Network")
7
+ //
8
+ // This file is part of the ONCHAINID smart contract suite.
9
+ //
10
+ // This program is free software: you can redistribute it and/or modify
11
+ // it under the terms of the GNU General Public License as published by
12
+ // the Free Software Foundation, either version 3 of the License, or
13
+ // (at your option) any later version.
14
+ //
15
+ // This program is distributed in the hope that it will be useful,
16
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ // GNU General Public License for more details.
19
+ //
20
+ // You should have received a copy of the GNU General Public License
21
+ // along with this program. If not, see <https://www.gnu.org/licenses/>.
22
+
23
+ pragma solidity ^0.8.28;
24
+
25
+ import { KeyManager } from "./KeyManager.sol";
26
+ import { Errors } from "./libraries/Errors.sol";
27
+ import { hashAddress } from "./libraries/Hashing.sol";
28
+ import { KeyPurposes } from "./libraries/KeyPurposes.sol";
29
+ import { ERC734Validator } from "./modules/validators/ERC734Validator.sol";
30
+ import { SafeCalldataBatch } from "./vendor/utils/SafeCalldataBatch.sol";
31
+ import {
32
+ AccountERC7579Upgradeable
33
+ } from "@openzeppelin/contracts-upgradeable/account/extensions/draft-AccountERC7579Upgradeable.sol";
34
+ import { ERC4337Utils } from "@openzeppelin/contracts/account/utils/ERC4337Utils.sol";
35
+ import { CallType, ERC7579Utils, ExecType, Mode } from "@openzeppelin/contracts/account/utils/draft-ERC7579Utils.sol";
36
+ import {
37
+ Execution,
38
+ MODULE_TYPE_EXECUTOR,
39
+ MODULE_TYPE_FALLBACK
40
+ } from "@openzeppelin/contracts/interfaces/draft-IERC7579.sol";
41
+ import { Calldata } from "@openzeppelin/contracts/utils/Calldata.sol";
42
+ import { EIP712 } from "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
43
+
44
+ /// @title SmartAccount
45
+ /// @notice ERC-7579 modular account that uses the ERC-734 key registry from {KeyManager}.
46
+ /// Signature checks happen in the installed validator, and the account does not
47
+ /// re-check a user op the validator accepted; the per-target purpose rule in
48
+ /// {_authorizeCall} applies to executor callers only.
49
+ abstract contract SmartAccount is KeyManager, AccountERC7579Upgradeable, EIP712 {
50
+
51
+ /// @notice Install a module. Gated on MANAGEMENT.
52
+ /// @dev The OZ default gate (`onlyEntryPointOrSelf`) is replaced with the stricter
53
+ /// ERC-734 `onlyManagerOrSelf` check, and `_installModule` is invoked directly instead
54
+ /// of `super.installModule`. The translated gate is at least as strict as the
55
+ /// OZ default, because the only paths that satisfied `onlyEntryPointOrSelf` were
56
+ /// (a) the canonical EntryPoint, which in turn ran a MANAGEMENT-signed UserOp,
57
+ /// or (b) the identity calling itself, which can only be reached via a
58
+ /// MANAGEMENT-authorized executor. The override lets a MANAGEMENT key holder
59
+ /// install or rotate modules directly, without round-tripping through an
60
+ /// EntryPoint or a self-call. Closing issue #6 as "won't fix" per design.
61
+ /// @dev Fallback handler wiring: `module` must be a contract. If it resolves to an
62
+ /// EOA (or any non-zero address with no code), policy queries hit the strict
63
+ /// default and the fallback silently degrades. Don't install fallbacks on EOAs.
64
+ /// @dev Installing a validator hands it the job of authorizing user ops. The account does not
65
+ /// re-check a user op the validator accepted, so the validator's signers get whatever
66
+ /// authority the validator gives them. If a validator does not restrict its signers, they
67
+ /// can even reach self-modifying calls like addKey. So only install validators you trust to
68
+ /// scope their keys; the enshrined {ERC734Validator} does. This is not an escalation:
69
+ /// installing the validator in the first place already needs MANAGEMENT.
70
+ function installModule(uint256 moduleTypeId, address module, bytes calldata initData)
71
+ public
72
+ virtual
73
+ override
74
+ onlyManagerOrSelf
75
+ {
76
+ _installModule(moduleTypeId, module, initData);
77
+ }
78
+
79
+ /// @notice Uninstall a module. MANAGEMENT-gated.
80
+ /// @dev See {installModule} for the rationale behind replacing the OZ default
81
+ /// `onlyEntryPointOrSelf` gate with `onlyManagerOrSelf` and bypassing `super`.
82
+ function uninstallModule(uint256 moduleTypeId, address module, bytes calldata deInitData)
83
+ public
84
+ virtual
85
+ override
86
+ onlyManagerOrSelf
87
+ {
88
+ _uninstallModule(moduleTypeId, module, deInitData);
89
+ }
90
+
91
+ /// @dev Strips every ERC-734 purpose the module holds, then runs the base uninstall.
92
+ /// Purposes are read from, and removed on, the enshrined registry module (self-calls).
93
+ /// Fallback uninstalls don't strip: fallback handlers register per selector, so one
94
+ /// module can hold several fallback installs (plus an executor one) all backed by a
95
+ /// single MODULE key. Dropping one selector must not revoke the key that still
96
+ /// authorizes the others; retiring a fallback-only module's key is an explicit
97
+ /// {removeKey}.
98
+ function _uninstallModule(uint256 moduleTypeId, address module, bytes memory deInitData) internal virtual override {
99
+ // Take away the module's ERC-734 purposes first, then run the base uninstall (which calls
100
+ // the module's onUninstall). Order matters: a module that still holds MANAGEMENT could use
101
+ // its onUninstall callback to grant itself keys. Stripping first closes that window.
102
+ if (moduleTypeId != MODULE_TYPE_FALLBACK) {
103
+ bytes32 moduleKey = hashAddress(module);
104
+ ERC734Validator registry = ERC734Validator(registryModule());
105
+
106
+ // Drop each purpose the module holds. Snapshot first, since the set shrinks as we remove.
107
+ // At most the 6 ERC-734 purposes, so the loop is cheap. Skip if the module had no key.
108
+ (bytes memory signerData,) = registry.getKeyData(address(this), moduleKey);
109
+ if (signerData.length != 0) {
110
+ uint256[] memory purposes = registry.getKeyPurposes(address(this), moduleKey);
111
+ for (uint256 i = 0; i < purposes.length; i++) {
112
+ _removeKeyPurpose(moduleKey, purposes[i]);
113
+ }
114
+ }
115
+ }
116
+
117
+ super._uninstallModule(moduleTypeId, module, deInitData);
118
+ }
119
+
120
+ /// @notice Advertises the modes {_execute} accepts. The OZ base also claims DELEGATECALL,
121
+ /// which {_execute} rejects.
122
+ function supportsExecutionMode(bytes32 encodedMode) public view virtual override returns (bool) {
123
+ (CallType callType, ExecType execType,,) = ERC7579Utils.decodeMode(Mode.wrap(encodedMode));
124
+ return (callType == ERC7579Utils.CALLTYPE_SINGLE || callType == ERC7579Utils.CALLTYPE_BATCH)
125
+ && (execType == ERC7579Utils.EXECTYPE_DEFAULT || execType == ERC7579Utils.EXECTYPE_TRY);
126
+ }
127
+
128
+ /// @notice The one place every dispatched call is authorized. Both `execute` (user ops and
129
+ /// MANAGEMENT self-calls) and {executeFromExecutor} go through here, so there is only one
130
+ /// authorization path to keep right. DELEGATECALL and unknown call types are rejected.
131
+ function _execute(Mode mode, bytes calldata executionCalldata) internal virtual override returns (bytes[] memory) {
132
+ // Work out who is calling: their key hash, and whether they are an installed executor
133
+ // (which gets purpose-checked).
134
+ bytes32 callerKeyHash = hashAddress(msg.sender);
135
+ bool callerIsExecutor = isModuleInstalled(MODULE_TYPE_EXECUTOR, msg.sender, Calldata.emptyBytes());
136
+
137
+ (CallType callType,,,) = ERC7579Utils.decodeMode(mode);
138
+
139
+ if (callType == ERC7579Utils.CALLTYPE_SINGLE) {
140
+ // SINGLE layout: target (20) | value (32) | data. A shorter payload is malformed;
141
+ // reject it here so a call can never skip the guard below and reach super unauthorized.
142
+ require(executionCalldata.length >= 52, Errors.UnsupportedExecutionMode(Mode.unwrap(mode)));
143
+ address target = address(bytes20(executionCalldata[:20]));
144
+ _authorizeCall(target, executionCalldata[52:], callerKeyHash, callerIsExecutor);
145
+ } else if (callType == ERC7579Utils.CALLTYPE_BATCH) {
146
+ // Every call in the batch must pass. {SafeCalldataBatch} keeps the batch in calldata but
147
+ // validates each entry against the slice bounds, so a backward offset can't point past
148
+ // the batch and let us authorize a different target than we run. The validator decodes
149
+ // the same way, so the two checks always agree.
150
+ Execution[] calldata batch = SafeCalldataBatch.decodeBatch(executionCalldata);
151
+ for (uint256 i = 0; i < batch.length; i++) {
152
+ _authorizeCall(batch[i].target, batch[i].callData, callerKeyHash, callerIsExecutor);
153
+ }
154
+ } else {
155
+ revert Errors.UnsupportedExecutionMode(Mode.unwrap(mode));
156
+ }
157
+
158
+ return super._execute(mode, executionCalldata);
159
+ }
160
+
161
+ /// @dev Authorizes one call: no dispatched call may target one of the account's own modules
162
+ /// (unless the account itself is the caller), and an executor caller needs a key
163
+ /// purpose for the target.
164
+ function _authorizeCall(address target, bytes calldata inner, bytes32 callerKeyHash, bool callerIsExecutor)
165
+ private
166
+ view
167
+ {
168
+ // OZ rewrites target 0 to the account before dispatch; do the same so the checks agree.
169
+ if (target == address(0)) target = address(this);
170
+
171
+ // A dispatched call must never land on one of the account's own modules: an installed
172
+ // executor, or the fallback handler for this call's selector. Module functions are reached
173
+ // through the account's fallback dispatch, which appends the real caller (ERC-2771 style);
174
+ // `execute(module, ...)` skips that append, so the module would misread its caller.
175
+ // `bytes4(inner)` zero-pads short/empty calldata, which matches no handler.
176
+ //
177
+ // Exception: the account itself may call its own modules. Some module functions only
178
+ // accept the account as caller (the recovery module's cancel and its config setters),
179
+ // and this is the only way to reach them. A self-call to `execute` always comes from a
180
+ // MANAGEMENT-authorized flow, so nothing is escalated.
181
+ bool targetIsOwnModule = isModuleInstalled(MODULE_TYPE_EXECUTOR, target, Calldata.emptyBytes())
182
+ || _fallbackHandler(bytes4(inner)) == target;
183
+ if (targetIsOwnModule && msg.sender != address(this)) {
184
+ revert Errors.OwnModuleTargetBlocked(target);
185
+ }
186
+
187
+ // An executor's own key must have a purpose that authorizes this target.
188
+ if (callerIsExecutor && !_isKeyAuthorizedToCallTarget(callerKeyHash, target)) {
189
+ revert Errors.ExecutorPurposeNotAuthorized();
190
+ }
191
+ }
192
+
193
+ /// @dev The purpose an executor's key needs for a target. Management-grade targets need
194
+ /// MANAGEMENT; any other target needs ACTION. MANAGEMENT satisfies every purpose check.
195
+ /// The factory is management-grade because its wallet-binding calls (linkAccount,
196
+ /// revokeAccount, settlePendingCrossChainLink) change the identity's own bindings.
197
+ function _isKeyAuthorizedToCallTarget(bytes32 keyHash, address target) private view returns (bool) {
198
+ uint256 requiredPurpose = isManagementTarget(target) ? KeyPurposes.MANAGEMENT : KeyPurposes.ACTION;
199
+ return _moduleKeyHasPurpose(keyHash, requiredPurpose);
200
+ }
201
+
202
+ /// @notice Whether a call to `target` needs MANAGEMENT rather than ACTION. Management-grade
203
+ /// targets are the account itself, its factory (whose wallet-binding calls change the
204
+ /// identity's own bindings), and the enshrined key registry (whose addKey/removeKey run
205
+ /// under the account and rewrite its own key set). Read by executor modules (e.g.
206
+ /// {KeyApprovalModule}) so they match this dispatch guard.
207
+ /// @dev Target-level only (MANAGEMENT vs ACTION); it does not resolve per-selector granularity,
208
+ /// so callers that host selector-specific purposes handle those separately.
209
+ /// @dev {ERC734Validator} keeps its own copy instead: calling the account during ERC-4337
210
+ /// validation would break ERC-7562 bundler rules. It self-guards the registry there via
211
+ /// `target == address(this)`.
212
+ function isManagementTarget(address target) public view returns (bool) {
213
+ // OZ aliases target 0 to the account before dispatch; match that so the checks agree.
214
+ if (target == address(0)) target = address(this);
215
+ return target == address(this) || target == identityFactory() || target == registryModule();
216
+ }
217
+
218
+ /// @notice The factory that deployed this identity. Implemented by the concrete account
219
+ /// ({Identity}) as an immutable, so it costs no storage access and no module hop.
220
+ function identityFactory() public view virtual returns (address);
221
+
222
+ }
@@ -0,0 +1,325 @@
1
+ // SPDX-License-Identifier: GPL-3.0
2
+ //
3
+ // ONCHAINID Smart Contracts
4
+ // Digital identities for the T-REX ecosystem.
5
+ //
6
+ // Copyright (C) 2026 Digital Asset Operational Services ISAC Ltd. ("T-REX Network")
7
+ //
8
+ // This file is part of the ONCHAINID smart contract suite.
9
+ //
10
+ // This program is free software: you can redistribute it and/or modify
11
+ // it under the terms of the GNU General Public License as published by
12
+ // the Free Software Foundation, either version 3 of the License, or
13
+ // (at your option) any later version.
14
+ //
15
+ // This program is distributed in the hope that it will be useful,
16
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ // GNU General Public License for more details.
19
+ //
20
+ // You should have received a copy of the GNU General Public License
21
+ // along with this program. If not, see <https://www.gnu.org/licenses/>.
22
+
23
+ pragma solidity ^0.8.27;
24
+
25
+ import { Structs } from "../storage/Structs.sol";
26
+
27
+ /// @title IIdentityFactory
28
+ /// @notice Factory for ONCHAINID identity proxies. Deployment is gated per identity type
29
+ /// using an OpenZeppelin AccessManager as the role oracle.
30
+ ///
31
+ /// Admin must register each type up front via {setIdentityTypePolicy}. The policy
32
+ /// carries an AM role id (gates {createIdentityFor}) and a `selfDeployable` flag
33
+ /// (gates {createIdentity}). Unregistered types revert from both entry points.
34
+ /// Use the AM's `PUBLIC_ROLE` for open types; any other role restricts the call to
35
+ /// its holders.
36
+ ///
37
+ /// Admin also registers the modules each type deploys with, via
38
+ /// {setIdentityTypeModules}. Callers pass no modules, so the admin decides which
39
+ /// code runs on an identity and with which purpose.
40
+ ///
41
+ /// Both setters are `restricted` (resolved by the AM).
42
+ ///
43
+ /// Wallets are addressed as ERC-7930 interoperable address envelopes (`bytes`).
44
+ /// EVM wallets are wrapped via OZ `InteroperableAddress.formatEvmV1(chainId, addr)`.
45
+ /// Non-EVM wallets (Solana, Bitcoin, Stellar, ...) supply the envelope for their
46
+ /// own chain; ERC-7913 signers (passkeys, WebAuthn, custom verifiers) are linked
47
+ /// the same way once wrapped into an envelope. The registry treats signers and
48
+ /// wallets the same; whatever can sign for an identity can also be linked as a
49
+ /// wallet on it.
50
+ ///
51
+ /// Proof of control for the wallet being linked depends on the wallet's chain.
52
+ /// For EVM and ERC-7913 signers, {linkAccount} runs the signature check on-chain
53
+ /// via `SignatureChecker`. For non-EVM wallets, the wallet proves control on its
54
+ /// native chain and the proof is relayed through an ERC-7786 cross-chain message;
55
+ /// the named identity then calls {settlePendingCrossChainLink} on this chain. Both
56
+ /// halves (wallet control + identity ownership) are required, with one inbound
57
+ /// message.
58
+ ///
59
+ /// Bindings are sticky: once linked, a wallet stays bound to that identity, even
60
+ /// after revocation. Revocation flips the status to `Revoked` and the wallet can
61
+ /// never be relinked to any identity. The wallet -> identity record stays
62
+ /// on-chain so compliance modules can resolve historical ownership.
63
+ /// Token recovery for tokens still sitting in a revoked wallet is the policy of
64
+ /// the compliance / token modules, not this registry; ONCHAINID only guarantees
65
+ /// the link is visible and immutable.
66
+ ///
67
+ /// Tokens share the same keyspace as wallets: an ASSET identity's auto-linked
68
+ /// wallet is the token, looked up via `getIdentity(bytes)` or
69
+ /// `getAccounts(identity, 0, 1)[0]`.
70
+ interface IIdentityFactory {
71
+
72
+ /// @notice Lifecycle state of a wallet entry. `None` means "never seen" and is
73
+ /// distinct from `Revoked` (which keeps the binding on-chain).
74
+ enum AccountStatus {
75
+ None,
76
+ Active,
77
+ Revoked
78
+ }
79
+
80
+ // event emitted when a wallet is linked to an identity
81
+ event AccountLinked(bytes account, address indexed identity);
82
+
83
+ // event emitted when a wallet is revoked from its identity (binding stays on-chain, status flips)
84
+ event AccountRevoked(bytes account, address indexed identity);
85
+
86
+ /// @notice Emitted when the policy for a given identity type is set. Setting a policy
87
+ /// registers the type. `selfDeployable` gates {createIdentity}: true allows
88
+ /// self-deploy, false reserves the type for {createIdentityFor}. `singleBinding`
89
+ /// marks types bound to one contract (ASSET, SMART_CONTRACT): they keep the
90
+ /// account set at deploy and can never link or revoke another.
91
+ event IdentityTypePolicySet(
92
+ uint256 indexed identityType, uint64 indexed roleId, bool selfDeployable, bool singleBinding
93
+ );
94
+
95
+ /// @notice Emitted when an identity type is unregistered (both deploy paths revert).
96
+ event IdentityTypePolicyRemoved(uint256 indexed identityType);
97
+
98
+ /// @notice Emitted when the modules registered for an identity type change. Every
99
+ /// identity of that type installs these from then on.
100
+ event IdentityTypeModulesSet(uint256 indexed identityType, Structs.ModuleInstall[] modules);
101
+
102
+ /// @notice Emitted when an inbound ERC-7786 message has staged a wallet -> identity
103
+ /// binding awaiting identity-side confirmation. The link is not active yet.
104
+ event PendingCrossChainLinkProposed(bytes account, address indexed identity, uint256 expiry);
105
+
106
+ /// @notice Emitted when an identity confirms a pending cross-chain proposal and the
107
+ /// wallet becomes active.
108
+ event CrossChainLinkConfirmed(bytes account, address indexed identity);
109
+
110
+ /// @notice Emitted when an identity declines a pending cross-chain proposal. The
111
+ /// proposal is deleted and no binding is created; the wallet stays unlinked
112
+ /// and can be proposed again later.
113
+ event CrossChainLinkRejected(bytes account, address indexed identity, uint256 expiry);
114
+
115
+ /// @notice Emitted when admin adds or removes an authorized ERC-7786 gateway
116
+ /// for one origin chain.
117
+ event TrustedGatewaySet(address indexed gateway, bytes2 chainType, bytes chainReference, bool trusted);
118
+
119
+ /// @notice Emitted when admin adds or removes an approved ERC-7913 verifier.
120
+ event TrustedVerifierSet(address indexed verifier, bool trusted);
121
+
122
+ /// @notice Emitted when the beacon is deployed via {initializeBeacon}.
123
+ event BeaconInitialized(address indexed implementation);
124
+
125
+ /// @notice Emitted when the beacon implementation is upgraded via {upgradeBeacon}.
126
+ event BeaconUpgraded(address indexed implementation);
127
+
128
+ /// @notice One-shot bootstrap: deploys the OZ UpgradeableBeacon at the factory's
129
+ /// predetermined CREATE3 slot ({beacon}), pointing at `implementation` and
130
+ /// owned by the factory itself. Needed because the beacon can only exist
131
+ /// after this factory does (it needs the Identity implementation, which needs
132
+ /// the enshrined validator, which needs this factory's address). Restricted.
133
+ function initializeBeacon(address implementation) external;
134
+
135
+ /// @notice Upgrade the implementation every deployed identity delegates to. The factory
136
+ /// owns the beacon, so this is the only upgrade path, and it is gated by the
137
+ /// factory's current authority. The candidate must name this factory, keep the
138
+ /// registry module the outgoing implementation names, have its initializers
139
+ /// disabled, and report `expectedVersion` from {Identity.version}, so a build
140
+ /// that forgot the version bump is rejected. Restricted.
141
+ function upgradeBeacon(address newImplementation, string calldata expectedVersion) external;
142
+
143
+ /// @notice Self-deploy. Caller is the account being deployed for and is auto-linked
144
+ /// as the new identity's first wallet. Gated per type by `selfDeployable`:
145
+ /// contract-shaped types like ASSET / SMART_CONTRACT opt out because the
146
+ /// `msg.sender = first wallet` binding does not apply to them. Unregistered
147
+ /// types revert.
148
+ /// The modules registered for the type are installed. Callers do not pick them.
149
+ function createIdentity(uint256 _identityType, string memory _salt, Structs.KeyParam[] memory _keys)
150
+ external
151
+ returns (address);
152
+
153
+ /// @notice Deploy for another EVM account. The account is auto-linked as the
154
+ /// identity's first wallet. Caller must hold the role configured for
155
+ /// `_identityType`. Unregistered types revert.
156
+ ///
157
+ /// `_account` signs nothing, so an issuer can onboard a wallet without asking
158
+ /// its owner for anything. The deploy instead only succeeds if `_account` ends
159
+ /// up as the only wallet with MANAGEMENT on the new identity, so the identity is
160
+ /// managed by the wallet it was created for and never by the caller. The type's
161
+ /// registered modules may hold MANAGEMENT too, but callers do not choose modules,
162
+ /// so a caller cannot act through one either. Single binding types (ASSET,
163
+ /// SMART_CONTRACT) hold no key, so they skip the check and rely on the caller's
164
+ /// role, which must not be `PUBLIC_ROLE`.
165
+ function createIdentityFor(
166
+ address _account,
167
+ uint256 _identityType,
168
+ string memory _salt,
169
+ Structs.KeyParam[] memory _keys
170
+ ) external returns (address);
171
+
172
+ /// @notice Set the per-type policy: AM role required to call {createIdentityFor},
173
+ /// whether {createIdentity} (self-deploy) is allowed, and whether the type is
174
+ /// single-binding. Pass `_singleBinding = true` for types bound to one contract
175
+ /// (ASSET, SMART_CONTRACT, ...): they keep the account set at deploy and can
176
+ /// never link or revoke another. Setting a policy registers the type;
177
+ /// registration is tracked separately from the role, so the AM's `ADMIN_ROLE`
178
+ /// (id 0) is usable like any other role. `restricted` via the AM.
179
+ function setIdentityTypePolicy(uint256 _identityType, uint64 _roleId, bool _selfDeployable, bool _singleBinding)
180
+ external;
181
+
182
+ /// @notice Unregister an identity type (both deploy paths will revert). `restricted`
183
+ /// via the AM.
184
+ function removeIdentityTypePolicy(uint256 _identityType) external;
185
+
186
+ /// @notice Read the per-type policy. `registered == false` means the type is
187
+ /// unregistered and both deploy paths revert.
188
+ function getIdentityTypePolicy(uint256 _identityType)
189
+ external
190
+ view
191
+ returns (uint64 roleId, bool selfDeployable, bool singleBinding, bool registered);
192
+
193
+ /// @notice Set the modules installed on every identity of `_identityType`, replacing
194
+ /// any list set before. Deploy callers pass no modules, so this is the only way
195
+ /// a module reaches an identity, and the admin decides which code runs with
196
+ /// which purpose. A type with no modules registered cannot deploy, because
197
+ /// `Identity.initialize` needs a validator or an executor. `restricted`.
198
+ function setIdentityTypeModules(uint256 _identityType, Structs.ModuleInstall[] calldata _modules) external;
199
+
200
+ /// @notice Read the modules registered for an identity type.
201
+ function getIdentityTypeModules(uint256 _identityType) external view returns (Structs.ModuleInstall[] memory);
202
+
203
+ /// @notice Link a wallet to the calling identity. The wallet authorizes the link via
204
+ /// an EIP-712 `LinkAccount` signature. Supports EOAs, ERC-1271 smart wallets,
205
+ /// and ERC-7913 verifiers (passkeys, etc.) uniformly via `SignatureChecker`.
206
+ /// ERC-7913 signers only link when their verifier is approved via
207
+ /// {setTrustedVerifier}.
208
+ ///
209
+ /// @param account ERC-7930 interoperable address envelope. EVM wallets are wrapped
210
+ /// via OZ `InteroperableAddress.formatEvmV1(chainId, addr)`. The chain type
211
+ /// must be eip-155 and the chain reference must be the local chain id in
212
+ /// minimal big-endian form: the signature check cannot prove control on any
213
+ /// other chain, so envelopes for non-EVM or foreign EVM chains revert and
214
+ /// go through {settlePendingCrossChainLink} instead. Malformed envelopes revert.
215
+ /// @param signature EIP-712 signature produced by `account` over
216
+ /// `LinkAccount(bytes account,address identity,uint256 nonce,uint256 expiry)`.
217
+ /// @param nonce current nonce for `account` (see {nonceForAccount}).
218
+ /// @param expiry unix timestamp after which the signature is invalid. `expiry == 0`
219
+ /// reverts. Callers must set freshness explicitly because the binding is
220
+ /// permanent once consumed.
221
+ function linkAccount(bytes calldata account, bytes calldata signature, uint256 nonce, uint256 expiry) external;
222
+
223
+ /// @notice Revoke a wallet from the calling identity. The wallet→identity record
224
+ /// remains on-chain; status flips to `Revoked`. A revoked wallet can never
225
+ /// be re-linked (terminal revocation).
226
+ ///
227
+ /// Revoking the identity's last wallet only retires that address: wallet
228
+ /// links and ERC-734 keys are separate namespaces, so the identity's keys
229
+ /// are untouched and a MANAGEMENT key can still drive {linkAccount} to bind
230
+ /// a fresh wallet. Integrators must not treat an identity whose active set
231
+ /// is momentarily empty as dead.
232
+ function revokeAccount(bytes calldata account) external;
233
+
234
+ /// @notice Settle a cross-chain link previously proposed via an authenticated
235
+ /// ERC-7786 message. Caller must be the identity named in the proposal —
236
+ /// that's the identity-ownership half of the proof. The wallet-control
237
+ /// half came from the inbound message.
238
+ ///
239
+ /// Either way the proposal is deleted, so an identity that declines (or
240
+ /// never got around to accepting) does not leave a dead entry behind.
241
+ ///
242
+ /// @param account the wallet envelope carried in the proposal.
243
+ /// @param accept `true` links the wallet, with the same sticky-binding rules as
244
+ /// any EVM-side link; reverts if the proposal has expired. `false`
245
+ /// declines and clears the proposal, allowed at any time including after
246
+ /// expiry. Declining creates no binding, so the wallet stays unlinked and
247
+ /// may be proposed again later.
248
+ function settlePendingCrossChainLink(bytes calldata account, bool accept) external;
249
+
250
+ /// @notice Read a pending cross-chain proposal. Returns (address(0), 0) when no
251
+ /// proposal is staged for `account`.
252
+ function getPendingCrossChainLink(bytes calldata account) external view returns (address identity, uint256 expiry);
253
+
254
+ /// @notice Add or remove an authorized ERC-7786 gateway for one origin chain.
255
+ /// The origin is the ERC-7930 (chainType, chainReference) pair. A gateway
256
+ /// serving several origins needs one entry per origin; messages from any
257
+ /// other origin are rejected by {receiveMessage}. `restricted` via the AM
258
+ /// so the trust surface is operated by the same admin role as the rest of
259
+ /// the factory.
260
+ ///
261
+ /// Removing an entry blocks future inbound messages but does not purge
262
+ /// pending links it already staged. Operators should audit
263
+ /// {getPendingCrossChainLink} and treat entries proposed via the removed
264
+ /// gateway as suspect; the named identity clears one by calling
265
+ /// {settlePendingCrossChainLink} with `accept = false`.
266
+ function setTrustedGateway(address gateway, bytes2 chainType, bytes calldata chainReference, bool trusted) external;
267
+
268
+ /// @notice Read whether a gateway is currently trusted for one origin chain.
269
+ function isTrustedGateway(address gateway, bytes2 chainType, bytes calldata chainReference)
270
+ external
271
+ view
272
+ returns (bool);
273
+
274
+ /// @notice Add or remove an approved ERC-7913 verifier. {linkAccount} rejects
275
+ /// signers longer than 20 bytes whose leading verifier is not listed,
276
+ /// because the verifier judges its own signer's proof. `restricted` via
277
+ /// the AM.
278
+ ///
279
+ /// Listing a verifier means trusting its code to judge proof of
280
+ /// control. A permissive or buggy verifier lets any signer that names
281
+ /// it link without a genuine proof, so grant the role for this
282
+ /// function only to admins who vet verifier implementations.
283
+ function setTrustedVerifier(address verifier, bool trusted) external;
284
+
285
+ /// @notice Read whether an address is currently an approved ERC-7913 verifier.
286
+ function isTrustedVerifier(address verifier) external view returns (bool);
287
+
288
+ /// @notice Resolve a wallet to its bound identity. Returns `address(0)` when the
289
+ /// wallet's status is not `Active` (never linked, or revoked).
290
+ function getIdentity(bytes calldata account) external view returns (address);
291
+
292
+ /// @notice Same as {getIdentity}, but also returns the wallet's current lifecycle
293
+ /// status. Distinguishes "never linked" from "revoked".
294
+ function getIdentityIncludingRevoked(bytes calldata account)
295
+ external
296
+ view
297
+ returns (address identity, AccountStatus status);
298
+
299
+ /// @notice Read the current lifecycle status of a wallet entry.
300
+ function getAccountStatus(bytes calldata account) external view returns (AccountStatus);
301
+
302
+ /// @notice Enumerate the active wallets currently linked to `identity`, paginated
303
+ /// over `[start, end)` (out-of-range bounds are clamped). Each entry is the
304
+ /// ERC-7930 envelope that was used to link the wallet. Envelopes are
305
+ /// unbounded bytes and the set has no size cap, so read in pages sized to
306
+ /// the provider's eth_call gas cap; {getAccountsCount} gives the total.
307
+ function getAccounts(address identity, uint256 start, uint256 end) external view returns (bytes[] memory);
308
+
309
+ /// @notice Number of active wallets currently linked to `identity`.
310
+ function getAccountsCount(address identity) external view returns (uint256);
311
+
312
+ /// @notice Returns true iff `identity` was deployed by this factory. Used by
313
+ /// {linkAccount} to reject pulls into non-OnchainID contracts.
314
+ function isFactoryIdentity(address identity) external view returns (bool);
315
+
316
+ /// @notice Current nonce for a signer. Keyed by `keccak256(account)` cast to address
317
+ /// so EVM and ERC-7913 signers share the same nonce store.
318
+ function nonceForAccount(bytes calldata account) external view returns (uint256);
319
+
320
+ /**
321
+ * @dev OZ UpgradeableBeacon every BeaconProxy deployed here delegates to.
322
+ */
323
+ function beacon() external view returns (address);
324
+
325
+ }