@t-rex-network/t-rex 5.0.0-beta2 → 5.0.0-beta3
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.
- package/NOTICE.md +78 -0
- package/README.md +19 -22
- package/contracts/{roles/AgentRole.sol → ERC-3643/ERC3643ErrorsLib.sol} +60 -33
- package/contracts/ERC-3643/IERC3643.sol +61 -5
- package/contracts/ERC-3643/IERC3643ClaimTopicsRegistry.sol +11 -2
- package/contracts/ERC-3643/IERC3643Compliance.sol +21 -8
- package/contracts/ERC-3643/IERC3643IdentityRegistry.sol +33 -0
- package/contracts/ERC-3643/IERC3643IdentityRegistryStorage.sol +62 -7
- package/contracts/ERC-3643/IERC3643TrustedIssuersRegistry.sol +29 -12
- package/contracts/ERC-3643/base/ERC3643ClaimTopicsRegistry.sol +140 -0
- package/contracts/ERC-3643/base/ERC3643Compliance.sol +223 -0
- package/contracts/ERC-3643/base/ERC3643IdentityRegistry.sol +382 -0
- package/contracts/ERC-3643/base/ERC3643IdentityRegistryStorage.sol +290 -0
- package/contracts/ERC-3643/base/ERC3643Token.sol +601 -0
- package/contracts/ERC-3643/base/ERC3643TrustedIssuersRegistry.sol +237 -0
- package/contracts/compliance/modular/ComplianceLedger.sol +175 -0
- package/contracts/compliance/modular/ComplianceLedgerLib.sol +120 -0
- package/contracts/compliance/modular/IComplianceLedger.sol +104 -0
- package/contracts/compliance/modular/IModularCompliance.sol +119 -28
- package/contracts/compliance/modular/ITransferValidation.sol +308 -0
- package/contracts/compliance/modular/ModularCompliance.sol +399 -240
- package/contracts/compliance/modular/ModuleSetLib.sol +182 -0
- package/contracts/compliance/modular/MovementKindLib.sol +97 -0
- package/contracts/compliance/modular/TransferContextLib.sol +140 -0
- package/contracts/compliance/modular/TransferValidation.sol +822 -0
- package/contracts/compliance/modular/TransferValidationLib.sol +183 -0
- package/contracts/compliance/modular/modules/AbstractModuleUpgradeable.sol +87 -56
- package/contracts/compliance/modular/modules/IModule.sol +142 -58
- package/contracts/compliance/modular/modules/MaxBalancePerIdentityModule.sol +175 -0
- package/contracts/compliance/modular/modules/ModuleProxy.sol +24 -24
- package/contracts/compliance/modular/modules/SpenderVerificationModule.sol +149 -0
- package/contracts/compliance/modular/modules/SpenderWhitelistModule.sol +215 -0
- package/contracts/factory/ITREXFactory.sol +94 -44
- package/contracts/factory/TREXFactory.sol +408 -201
- package/contracts/interop/ISettlementHandler.sol +101 -0
- package/contracts/interop/ITREXMessaging.sol +166 -0
- package/contracts/{proxy/ModularComplianceProxy.sol → interop/ITrustedGatewayRegistry.sol} +48 -43
- package/contracts/interop/TREXMessaging.sol +189 -0
- package/contracts/interop/TREXMessagingLib.sol +425 -0
- package/contracts/{proxy/TrustedIssuersRegistryProxy.sol → interop/TrustedGatewayRegistry.sol} +46 -37
- package/contracts/libraries/AccessManagerSetupLib.sol +484 -0
- package/contracts/libraries/ErrorsLib.sol +172 -65
- package/contracts/libraries/EventsLib.sol +168 -66
- package/contracts/libraries/MessageTypesLib.sol +259 -0
- package/contracts/libraries/RolesLib.sol +146 -0
- package/contracts/{roles/Roles.sol → libraries/VersionLib.sol} +46 -49
- package/contracts/libraries/WalletKeyLib.sol +156 -0
- package/contracts/proxy/beacon/ITREXImplementationAuthority.sol +157 -0
- package/contracts/proxy/beacon/TREXImplementationAuthority.sol +188 -0
- package/contracts/registry/implementation/IdentityRegistryStorage.sol +215 -163
- package/contracts/registry/implementation/TREXRegistry.sol +475 -0
- package/contracts/registry/interface/IIdentityRegistryStorage.sol +30 -25
- package/contracts/registry/interface/ITREXRegistry.sol +180 -0
- package/contracts/token/IToken.sol +210 -49
- package/contracts/token/Token.sol +411 -476
- package/contracts/token/TokenDelegationLib.sol +339 -0
- package/contracts/token/TokenGuardsLib.sol +123 -0
- package/contracts/token/TokenLedgerLib.sol +316 -0
- package/contracts/token/TokenRecoveryLib.sol +130 -0
- package/contracts/{roles/AgentRoleUpgradeable.sol → utils/AccessManagedOwnable.sol} +31 -31
- package/contracts/{proxy/IdentityRegistryStorageProxy.sol → utils/AccessManagedOwnableBase.sol} +56 -34
- package/contracts/utils/AccessManagedOwnableUpgradeable.sol +116 -0
- package/contracts/utils/IUtilityChecker.sol +32 -26
- package/contracts/{roles/AbstractAgentRole.sol → utils/TREXAccessManager.sol} +54 -57
- package/contracts/utils/UtilityChecker.sol +175 -52
- package/contracts/utils/UtilityCheckerProxy.sol +24 -24
- package/contracts/{proxy/interface/IProxy.sol → vendor/IERC173.sol} +15 -28
- package/out/AbstractModuleUpgradeable.sol/AbstractModuleUpgradeable.json +1 -1
- package/out/AbstractSigner.sol/AbstractSigner.json +1 -0
- package/out/AccessManaged.sol/AccessManaged.json +1 -0
- package/out/AccessManagedOwnable.sol/AccessManagedOwnable.json +1 -0
- package/out/AccessManagedOwnableBase.sol/AccessManagedOwnableBase.json +1 -0
- package/out/AccessManagedOwnableUpgradeable.sol/AccessManagedOwnableUpgradeable.json +1 -0
- package/out/AccessManagedUpgradeable.sol/AccessManagedUpgradeable.json +1 -0
- package/out/AccessManager.sol/AccessManager.json +1 -0
- package/out/AccessManagerHelper.sol/AccessManagerHelper.json +1 -0
- package/out/AccessManagerSetupLib.sol/AccessManagerSetupLib.json +1 -0
- package/out/AccessManagerUpgradeable.sol/AccessManagerUpgradeable.json +1 -0
- package/out/Account.sol/Account.json +1 -0
- package/out/Address.sol/Address.json +1 -1
- package/out/Arrays.sol/Arrays.json +1 -1
- package/out/AuthorityUtils.sol/AuthorityUtils.json +1 -0
- package/out/Base.sol/CommonBase.json +1 -1
- package/out/Base.sol/ScriptBase.json +1 -1
- package/out/Base.sol/TestBase.json +1 -1
- package/out/Base64.sol/Base64.json +1 -0
- package/out/BeaconProxy.sol/BeaconProxy.json +1 -0
- package/out/BeaconProxyDeployer.sol/BeaconProxyDeployer.json +1 -0
- package/out/Bytes.sol/Bytes.json +1 -1
- package/out/Calldata.sol/Calldata.json +1 -0
- package/out/CapabilityModules.sol/AllTypesModule.json +1 -0
- package/out/CapabilityModules.sol/CappedRecipientModule.json +1 -0
- package/out/CapabilityModules.sol/DelegatedCapRuleModule.json +1 -0
- package/out/CapabilityModules.sol/DuplicateTypeModule.json +1 -0
- package/out/CapabilityModules.sol/LockedSenderModule.json +1 -0
- package/out/CapabilityModules.sol/NoTypeModule.json +1 -0
- package/out/CapabilityModules.sol/RecordingModule.json +1 -0
- package/out/CapabilityModules.sol/RuleAndMintTrackerModule.json +1 -0
- package/out/CapabilityModules.sol/RuleAndTrackerModule.json +1 -0
- package/out/CapabilityModules.sol/RuleOnlyModule.json +1 -0
- package/out/CapabilityModules.sol/SpenderOnlyModule.json +1 -0
- package/out/CapabilityModules.sol/TrackerOnlyModule.json +1 -0
- package/out/CapabilityModules.sol/UndeclaredRuleModule.json +1 -0
- package/out/CapabilityModules.sol/WritingRuleModule.json +1 -0
- package/out/ClaimIssuerAlwaysReverts.sol/ClaimIssuerAlwaysReverts.json +1 -0
- package/out/ClaimIssuerTrick.sol/ClaimIssuerTrick.json +1 -1
- package/out/Comparators.sol/Comparators.json +1 -1
- package/out/ComplianceLedger.sol/ComplianceLedger.json +1 -0
- package/out/ComplianceLedgerLib.sol/ComplianceLedgerLib.json +1 -0
- package/out/Context.sol/Context.json +1 -1
- package/out/ContextUpgradeable.sol/ContextUpgradeable.json +1 -1
- package/out/Countries.sol/Countries.json +1 -1
- package/out/Create2.sol/Create2.json +1 -1
- package/out/Create3.sol/Create3.json +1 -1
- package/out/DeployComplianceModules.s.sol/DeployComplianceModules.json +1 -0
- package/out/DeployComplianceModules.s.sol/ITokenCompliance.json +1 -0
- package/out/DeployUtilityChecker.s.sol/DeployUtilityChecker.json +1 -0
- package/out/ECDSA.sol/ECDSA.json +1 -1
- package/out/EIP712.sol/EIP712.json +1 -1
- package/out/EIP712Upgradeable.sol/EIP712Upgradeable.json +1 -1
- package/out/ERC165.sol/ERC165.json +1 -0
- package/out/ERC165Checker.sol/ERC165Checker.json +1 -0
- package/out/ERC165Upgradeable.sol/ERC165Upgradeable.json +1 -0
- package/out/ERC1967Proxy.sol/ERC1967Proxy.json +1 -1
- package/out/ERC1967Utils.sol/ERC1967Utils.json +1 -1
- package/out/ERC20.sol/ERC20.json +1 -1
- package/out/ERC20Pausable.sol/ERC20Pausable.json +1 -1
- package/out/ERC20PermitUpgradeable.sol/ERC20PermitUpgradeable.json +1 -1
- package/out/ERC20Upgradeable.sol/ERC20Upgradeable.json +1 -1
- package/out/ERC3643ClaimTopicsRegistry.sol/ERC3643ClaimTopicsRegistry.json +1 -0
- package/out/ERC3643Compliance.sol/ERC3643Compliance.json +1 -0
- package/out/ERC3643ErrorsLib.sol/ERC3643ErrorsLib.json +1 -0
- package/out/ERC3643IdentityRegistry.sol/ERC3643IdentityRegistry.json +1 -0
- package/out/ERC3643IdentityRegistryStorage.sol/ERC3643IdentityRegistryStorage.json +1 -0
- package/out/ERC3643Token.sol/ERC3643Token.json +1 -0
- package/out/ERC3643TrustedIssuersRegistry.sol/ERC3643TrustedIssuersRegistry.json +1 -0
- package/out/ERC4337Utils.sol/ERC4337Utils.json +1 -0
- package/out/ERC4337Utils.sol/IEntryPointExtra.json +1 -0
- package/out/ERC734Validator.sol/ERC734Validator.json +1 -0
- package/out/ERC7579Validator.sol/ERC7579Validator.json +1 -0
- package/out/ERC7786GatewayMock.sol/ERC7786GatewayMock.json +1 -0
- package/out/ERC7786Recipient.sol/ERC7786Recipient.json +1 -0
- package/out/ERC7913WebAuthnVerifier.sol/ERC7913WebAuthnVerifier.json +1 -0
- package/out/EnumerableSet.sol/EnumerableSet.json +1 -1
- package/out/Errors.sol/Errors.json +1 -1
- package/out/ErrorsLib.sol/ErrorsLib.json +1 -1
- package/out/EventsLib.sol/EventsLib.json +1 -1
- package/out/Hashes.sol/Hashes.json +1 -0
- package/out/HostileModules.sol/RevertEverywhereModule.json +1 -0
- package/out/HostileModules.sol/UnbindRevertingModule.json +1 -0
- package/out/IAccessManaged.sol/IAccessManaged.json +1 -0
- package/out/IAccessManager.sol/IAccessManager.json +1 -0
- package/out/IAuthority.sol/IAuthority.json +1 -0
- package/out/IBeacon.sol/IBeacon.json +1 -1
- package/out/IClaimIssuer.sol/IClaimIssuer.json +1 -1
- package/out/IComplianceLedger.sol/IComplianceLedger.json +1 -0
- package/out/IERC1271.sol/IERC1271.json +1 -0
- package/out/IERC165.sol/IERC165.json +1 -1
- package/out/IERC173.sol/IERC173.json +1 -1
- package/out/IERC1967.sol/IERC1967.json +1 -1
- package/out/IERC20.sol/IERC20.json +1 -1
- package/out/IERC20Metadata.sol/IERC20Metadata.json +1 -1
- package/out/IERC20Permit.sol/IERC20Permit.json +1 -1
- package/out/IERC3643.sol/IERC3643.json +1 -1
- package/out/IERC3643ClaimTopicsRegistry.sol/IERC3643ClaimTopicsRegistry.json +1 -1
- package/out/IERC3643Compliance.sol/IERC3643Compliance.json +1 -1
- package/out/IERC3643IdentityRegistry.sol/IERC3643IdentityRegistry.json +1 -1
- package/out/IERC3643IdentityRegistryStorage.sol/IERC3643IdentityRegistryStorage.json +1 -1
- package/out/IERC3643TrustedIssuersRegistry.sol/IERC3643TrustedIssuersRegistry.json +1 -1
- package/out/IERC4337.sol/IAccount.json +1 -0
- package/out/IERC4337.sol/IAccountExecute.json +1 -0
- package/out/IERC4337.sol/IAggregator.json +1 -0
- package/out/IERC4337.sol/IEntryPoint.json +1 -0
- package/out/IERC4337.sol/IEntryPointNonces.json +1 -0
- package/out/IERC4337.sol/IEntryPointStake.json +1 -0
- package/out/IERC4337.sol/IPaymaster.json +1 -0
- package/out/IERC5267.sol/IERC5267.json +1 -1
- package/out/IERC734.sol/IERC734.json +1 -1
- package/out/IERC735.sol/IERC735.json +1 -1
- package/out/IERC7913.sol/IERC7913SignatureVerifier.json +1 -0
- package/out/IIdentity.sol/IIdentity.json +1 -1
- package/out/IIdentityFactory.sol/IIdentityFactory.json +1 -0
- package/out/IIdentityRegistryStorage.sol/IIdentityRegistryStorage.json +1 -1
- package/out/IKeyExecutor.sol/IKeyExecutor.json +1 -0
- package/out/IModularCompliance.sol/IModularCompliance.json +1 -1
- package/out/IModule.sol/IModule.json +1 -1
- package/out/IMulticall3.sol/IMulticall3.json +1 -1
- package/out/IReputationRegistry.sol/IReputationRegistry.json +1 -0
- package/out/ISettlementHandler.sol/ISettlementHandler.json +1 -0
- package/out/ITREXFactory.sol/ITREXFactory.json +1 -1
- package/out/ITREXImplementationAuthority.sol/ITREXImplementationAuthority.json +1 -1
- package/out/ITREXMessaging.sol/ITREXMessaging.json +1 -0
- package/out/ITREXRegistry.sol/ITREXRegistry.json +1 -0
- package/out/IToken.sol/IToken.json +1 -1
- package/out/ITransferValidation.sol/ITransferValidation.json +1 -0
- package/out/ITrustedGatewayRegistry.sol/ITrustedGatewayRegistry.json +1 -0
- package/out/IUtilityChecker.sol/IUtilityChecker.json +1 -1
- package/out/Identity.sol/Identity.json +1 -1
- package/out/IdentityFactory.sol/IdentityFactory.json +1 -0
- package/out/IdentityModulesHelper.sol/IdentityModulesHelper.json +1 -0
- package/out/IdentityRegistryStorage.sol/IdentityRegistryStorage.json +1 -1
- package/out/IdentityTypes.sol/IdentityTypes.json +1 -0
- package/out/Initializable.sol/Initializable.json +1 -1
- package/out/InteropSuiteTest.sol/InteropSuiteTest.json +1 -0
- package/out/KeyApprovalModule.sol/IIdentityAccount.json +1 -0
- package/out/KeyApprovalModule.sol/KeyApprovalModule.json +1 -0
- package/out/KeyManager.sol/KeyManager.json +1 -0
- package/out/KeyPurposes.sol/KeyPurposes.json +1 -1
- package/out/KeyTypes.sol/KeyTypes.json +1 -1
- package/out/LowLevelCall.sol/LowLevelCall.json +1 -1
- package/out/Math.sol/Math.json +1 -1
- package/out/MaxBalancePerIdentityModule.sol/MaxBalancePerIdentityModule.json +1 -0
- package/out/MessageHashUtils.sol/MessageHashUtils.json +1 -1
- package/out/MessageTypesLib.sol/MessageTypesLib.json +1 -0
- package/out/MockTREXAccessManagerV2.sol/MockTREXAccessManagerV2.json +1 -0
- package/out/MockTokenV2.sol/MockTokenV2.json +1 -0
- package/out/Mocks.sol/ClaimTopicsRegistryMock.json +1 -0
- package/out/Mocks.sol/ComplianceMock.json +1 -0
- package/out/Mocks.sol/IdentityRegistryMock.json +1 -0
- package/out/Mocks.sol/IdentityRegistryStorageMock.json +1 -0
- package/out/Mocks.sol/TokenMock.json +1 -0
- package/out/Mocks.sol/TrustedIssuersRegistryMock.json +1 -0
- package/out/ModularCompliance.sol/ModularCompliance.json +1 -1
- package/out/ModuleNotPnP.sol/ModuleNotPnP.json +1 -1
- package/out/ModuleProxy.sol/ModuleProxy.json +1 -1
- package/out/ModuleSetLib.sol/ModuleSetLib.json +1 -0
- package/out/MovementKindLib.sol/MovementKindLib.json +1 -0
- package/out/Multicall.sol/Multicall.json +1 -0
- package/out/MulticallUpgradeable.sol/MulticallUpgradeable.json +1 -1
- package/out/Nonces.sol/Nonces.json +1 -1
- package/out/NoncesUpgradeable.sol/NoncesUpgradeable.json +1 -1
- package/out/Ownable.sol/Ownable.json +1 -1
- package/out/OwnableUpgradeable.sol/OwnableUpgradeable.json +1 -1
- package/out/P256.sol/P256.json +1 -0
- package/out/Packing.sol/Packing.json +1 -0
- package/out/Panic.sol/Panic.json +1 -1
- package/out/Pausable.sol/Pausable.json +1 -1
- package/out/PausableUpgradeable.sol/PausableUpgradeable.json +1 -1
- package/out/Proxy.sol/Proxy.json +1 -1
- package/out/ReentrancyGuardTransient.sol/ReentrancyGuardTransient.json +1 -0
- package/out/ReentrantModule.sol/ReentrantModule.json +1 -0
- package/out/ReputationRegistry.sol/ReputationRegistry.json +1 -0
- package/out/RolesLib.sol/RolesLib.json +1 -0
- package/out/SafeCalldataBatch.sol/SafeCalldataBatch.json +1 -0
- package/out/SafeCast.sol/SafeCast.json +1 -1
- package/out/SatelliteLiteMock.sol/SatelliteLiteMock.json +1 -0
- package/out/Script.sol/Script.json +1 -0
- package/out/ShortStrings.sol/ShortStrings.json +1 -1
- package/out/SignatureChecker.sol/SignatureChecker.json +1 -0
- package/out/SignedMath.sol/SignedMath.json +1 -1
- package/out/SlotDerivation.sol/SlotDerivation.json +1 -1
- package/out/SmartAccount.sol/SmartAccount.json +1 -0
- package/out/SpenderVerificationModule.sol/SpenderVerificationModule.json +1 -0
- package/out/SpenderWhitelistModule.sol/SpenderWhitelistModule.json +1 -0
- package/out/StdAssertions.sol/StdAssertions.json +1 -1
- package/out/StdChains.sol/StdChains.json +1 -1
- package/out/StdCheats.sol/StdCheats.json +1 -1
- package/out/StdCheats.sol/StdCheatsSafe.json +1 -1
- package/out/StdConstants.sol/StdConstants.json +1 -1
- package/out/StdError.sol/stdError.json +1 -1
- package/out/StdInvariant.sol/StdInvariant.json +1 -1
- package/out/StdJson.sol/stdJson.json +1 -1
- package/out/StdMath.sol/stdMath.json +1 -1
- package/out/StdStorage.sol/stdStorage.json +1 -1
- package/out/StdStorage.sol/stdStorageSafe.json +1 -1
- package/out/StdStyle.sol/StdStyle.json +1 -1
- package/out/StdToml.sol/stdToml.json +1 -1
- package/out/StdUtils.sol/StdUtils.json +1 -1
- package/out/StorageSlot.sol/StorageSlot.json +1 -1
- package/out/Strings.sol/Strings.json +1 -1
- package/out/Structs.sol/Structs.json +1 -1
- package/out/TREXAccessManager.sol/TREXAccessManager.json +1 -0
- package/out/TREXFactory.sol/TREXFactory.json +1 -1
- package/out/TREXImplementationAuthority.sol/TREXImplementationAuthority.json +1 -1
- package/out/TREXMessaging.sol/TREXMessaging.json +1 -0
- package/out/TREXMessagingLib.sol/TREXMessagingLib.json +1 -0
- package/out/TREXRegistry.sol/TREXRegistry.json +1 -0
- package/out/TestERC20.sol/TestERC20.json +1 -1
- package/out/TestModule.sol/TestModule.json +1 -1
- package/out/TestTREXFactory.sol/TestTREXFactory.json +1 -1
- package/out/Time.sol/Time.json +1 -0
- package/out/Token.sol/Token.json +1 -1
- package/out/TokenDelegationLib.sol/TokenDelegationLib.json +1 -0
- package/out/TokenGuardsLib.sol/TokenGuardsLib.json +1 -0
- package/out/TokenHandler.sol/TokenHandler.json +1 -0
- package/out/TokenLedgerHarness.sol/TokenLedgerHarness.json +1 -0
- package/out/TokenLedgerLib.sol/TokenLedgerLib.json +1 -0
- package/out/TokenRecoveryLib.sol/TokenRecoveryLib.json +1 -0
- package/out/TokenReservationStub.sol/TokenReservationStub.json +1 -0
- package/out/TransferContextLib.sol/TransferContextLib.json +1 -0
- package/out/TransferValidation.sol/TransferValidation.json +1 -0
- package/out/TransferValidationHarness.sol/TransferValidationHarness.json +1 -0
- package/out/TransferValidationLib.sol/TransferValidationLib.json +1 -0
- package/out/TransientSlot.sol/TransientSlot.json +1 -0
- package/out/TrustedGatewayRegistry.sol/TrustedGatewayRegistry.json +1 -0
- package/out/UUPSUpgradeable.sol/UUPSUpgradeable.json +1 -1
- package/out/UpgradeableBeacon.sol/UpgradeableBeacon.json +1 -0
- package/out/UtilityChecker.sol/UtilityChecker.json +1 -1
- package/out/UtilityCheckerProxy.sol/UtilityCheckerProxy.json +1 -1
- package/out/Utils.sol/Utils.json +1 -1
- package/out/VersionLib.sol/VersionLib.json +1 -0
- package/out/Vm.sol/Vm.json +1 -1
- package/out/Vm.sol/VmSafe.json +1 -1
- package/out/WalletKeyLib.sol/WalletKeyLib.json +1 -0
- package/out/WebAuthn.sol/WebAuthn.json +1 -0
- package/out/console.sol/console.json +1 -1
- package/out/draft-AccountERC7579Upgradeable.sol/AccountERC7579Upgradeable.json +1 -0
- package/out/draft-ERC7579Utils.sol/ERC7579Utils.json +1 -0
- package/out/draft-IERC1822.sol/IERC1822Proxiable.json +1 -1
- package/out/draft-IERC6093.sol/IERC1155Errors.json +1 -1
- package/out/draft-IERC6093.sol/IERC20Errors.json +1 -1
- package/out/draft-IERC6093.sol/IERC721Errors.json +1 -1
- package/out/draft-IERC7579.sol/IERC7579AccountConfig.json +1 -0
- package/out/draft-IERC7579.sol/IERC7579Execution.json +1 -0
- package/out/draft-IERC7579.sol/IERC7579Hook.json +1 -0
- package/out/draft-IERC7579.sol/IERC7579Module.json +1 -0
- package/out/draft-IERC7579.sol/IERC7579ModuleConfig.json +1 -0
- package/out/draft-IERC7579.sol/IERC7579Validator.json +1 -0
- package/out/draft-IERC7786.sol/IERC7786GatewaySource.json +1 -0
- package/out/draft-IERC7786.sol/IERC7786Recipient.json +1 -0
- package/out/draft-InteroperableAddress.sol/InteroperableAddress.json +1 -0
- package/out/libraries/Errors.sol/Errors.json +1 -1
- package/out/safeconsole.sol/safeconsole.json +1 -1
- package/package.json +11 -7
- package/contracts/ERC-3643/ERC3643EventsLib.sol +0 -150
- package/contracts/factory/ITREXGateway.sol +0 -234
- package/contracts/factory/TREXGateway.sol +0 -274
- package/contracts/proxy/AbstractProxy.sol +0 -146
- package/contracts/proxy/ClaimTopicsRegistryProxy.sol +0 -83
- package/contracts/proxy/IdentityRegistryProxy.sol +0 -95
- package/contracts/proxy/TokenProxy.sol +0 -97
- package/contracts/proxy/authority/IAFactory.sol +0 -122
- package/contracts/proxy/authority/IIAFactory.sol +0 -87
- package/contracts/proxy/authority/ITREXImplementationAuthority.sol +0 -239
- package/contracts/proxy/authority/TREXImplementationAuthority.sol +0 -350
- package/contracts/registry/implementation/ClaimTopicsRegistry.sol +0 -152
- package/contracts/registry/implementation/IdentityRegistry.sol +0 -352
- package/contracts/registry/implementation/TrustedIssuersRegistry.sol +0 -272
- package/contracts/registry/interface/IClaimTopicsRegistry.sol +0 -70
- package/contracts/registry/interface/IIdentityRegistry.sol +0 -102
- package/contracts/registry/interface/ITrustedIssuersRegistry.sol +0 -70
- package/contracts/roles/IERC173.sol +0 -21
- package/contracts/token/TokenStructs.sol +0 -74
- package/contracts/utils/InterfaceIdCalculator.sol +0 -223
- package/contracts/vendor/openzeppelin/Create3.sol +0 -143
- package/out/AbstractAgentRole.sol/AbstractAgentRole.json +0 -1
- package/out/AbstractProxy.sol/AbstractProxy.json +0 -1
- package/out/AgentRole.sol/AgentRole.json +0 -1
- package/out/AgentRoleUpgradeable.sol/AgentRoleUpgradeable.json +0 -1
- package/out/ClaimIssuer.sol/ClaimIssuer.json +0 -1
- package/out/ClaimTopicsRegistry.sol/ClaimTopicsRegistry.json +0 -1
- package/out/ClaimTopicsRegistryProxy.sol/ClaimTopicsRegistryProxy.json +0 -1
- package/out/ERC2771Context.sol/ERC2771Context.json +0 -1
- package/out/ERC2771ContextUpgradeable.sol/ERC2771ContextUpgradeable.json +0 -1
- package/out/ERC2771Forwarder.sol/ERC2771Forwarder.json +0 -1
- package/out/ERC3643EventsLib.sol/ERC3643EventsLib.json +0 -1
- package/out/IAFactory.sol/IAFactory.json +0 -1
- package/out/IClaimTopicsRegistry.sol/IClaimTopicsRegistry.json +0 -1
- package/out/IERC1363.sol/IERC1363.json +0 -1
- package/out/IIAFactory.sol/IIAFactory.json +0 -1
- package/out/IIdFactory.sol/IIdFactory.json +0 -1
- package/out/IIdentityRegistry.sol/IIdentityRegistry.json +0 -1
- package/out/IImplementationAuthority.sol/IImplementationAuthority.json +0 -1
- package/out/IProxy.sol/IProxy.json +0 -1
- package/out/ITREXGateway.sol/ITREXGateway.json +0 -1
- package/out/ITrustedIssuersRegistry.sol/ITrustedIssuersRegistry.json +0 -1
- package/out/IdFactory.sol/IdFactory.json +0 -1
- package/out/IdentityProxy.sol/IdentityProxy.json +0 -1
- package/out/IdentityRegistry.sol/IdentityRegistry.json +0 -1
- package/out/IdentityRegistryProxy.sol/IdentityRegistryProxy.json +0 -1
- package/out/IdentityRegistryStorageProxy.sol/IdentityRegistryStorageProxy.json +0 -1
- package/out/ImplementationAuthority.sol/ImplementationAuthority.json +0 -1
- package/out/InterfaceIdCalculator.sol/InterfaceIdCalculator.json +0 -1
- package/out/ModularComplianceProxy.sol/ModularComplianceProxy.json +0 -1
- package/out/Ownable2Step.sol/Ownable2Step.json +0 -1
- package/out/Ownable2StepUpgradeable.sol/Ownable2StepUpgradeable.json +0 -1
- package/out/Roles.sol/Roles.json +0 -1
- package/out/SafeERC20.sol/SafeERC20.json +0 -1
- package/out/Storage.sol/Storage.json +0 -1
- package/out/TREXGateway.sol/TREXGateway.json +0 -1
- package/out/TestAgentRole.sol/TestAgentRole.json +0 -1
- package/out/TestAgentRoleUpgradeable.sol/TestAgentRoleUpgradeable.json +0 -1
- package/out/TokenProxy.sol/TokenProxy.json +0 -1
- package/out/TrustedIssuersRegistry.sol/TrustedIssuersRegistry.json +0 -1
- package/out/TrustedIssuersRegistryProxy.sol/TrustedIssuersRegistryProxy.json +0 -1
- package/out/Version.sol/Version.json +0 -1
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0
|
|
2
|
+
//
|
|
3
|
+
// :+#####%%%%%%%%%%%%%%+
|
|
4
|
+
// .-*@@@%+.:+%@@@@@%%#***%@@%=
|
|
5
|
+
// :=*%@@@#=. :#@@% *@@@%=
|
|
6
|
+
// .-+*%@%*-.:+%@@@@@@+. -*+: .=#. :%@@@%-
|
|
7
|
+
// :=*@@@@%%@@@@@@@@@%@@@- .=#@@@%@%= =@@@@#.
|
|
8
|
+
// -=+#%@@%#*=:. :%@@@@%. -*@@#*@@@@@@@#=:- *@@@@+
|
|
9
|
+
// =@@%=:. :=: *@@@@@%#- =%*%@@@@#+-. =+ :%@@@%-
|
|
10
|
+
// -@@%. .+@@@ =+=-. @@#- +@@@%- =@@@@%:
|
|
11
|
+
// :@@@. .+@@#%: : .=*=-::.-%@@@+*@@= +@@@@#.
|
|
12
|
+
// %@@: +@%%* =%@@@@@@@@@@@#. .*@%- +@@@@*.
|
|
13
|
+
// #@@= .+@@@@%:=*@@@@@- :%@%: .*@@@@+
|
|
14
|
+
// *@@* +@@@#-@@%-:%@@* +@@#. :%@@@@-
|
|
15
|
+
// -@@% .:-=++*##%%%@@@@@@@@@@@@*. :@+.@@@%: .#@@+ =@@@@#:
|
|
16
|
+
// .@@@*-+*#%%%@@@@@@@@@@@@@@@@%%#**@@%@@@. *@=*@@# :#@%= .#@@@@#-
|
|
17
|
+
// -%@@@@@@@@@@@@@@@*+==-:-@@@= *@# .#@*-=*@@@@%= -%@@@* =@@@@@%-
|
|
18
|
+
// -+%@@@#. %@%%= -@@:+@: -@@* *@@*-:: -%@@%=. .*@@@@@#
|
|
19
|
+
// *@@@* +@* *@@##@@- #@*@@+ -@@= . :+@@@#: .-+@@@%+-
|
|
20
|
+
// +@@@%*@@:..=@@@@* .@@@* .#@#. .=+- .=%@@@*. :+#@@@@*=:
|
|
21
|
+
// =@@@@%@@@@@@@@@@@@@@@@@@@@@@%- :+#*. :*@@@%=. .=#@@@@%+:
|
|
22
|
+
// .%@@= ..... .=#@@+. .#@@@*: -*%@@@@%+.
|
|
23
|
+
// +@@#+===---:::... .=%@@*- +@@@+. -*@@@@@%+.
|
|
24
|
+
// -@@@@@@@@@@@@@@@@@@@@@@%@@@@= -@@@+ -#@@@@@#=.
|
|
25
|
+
// ..:::---===+++***###%%%@@@#- .#@@+ -*@@@@@#=.
|
|
26
|
+
// @@@@@@+. +@@*. .+@@@@@%=.
|
|
27
|
+
// -@@@@@= =@@%: -#@@@@%+.
|
|
28
|
+
// +@@@@@. =@@@= .+@@@@@*:
|
|
29
|
+
// #@@@@#:%@@#. :*@@@@#-
|
|
30
|
+
// @@@@@%@@@= :#@@@@+.
|
|
31
|
+
// :@@@@@@@#.:#@@@%-
|
|
32
|
+
// +@@@@@@-.*@@@*:
|
|
33
|
+
// #@@@@#.=@@@+.
|
|
34
|
+
// @@@@+-%@%=
|
|
35
|
+
// :@@@#%@%=
|
|
36
|
+
// +@@@@%-
|
|
37
|
+
// :#%%=
|
|
38
|
+
//
|
|
39
|
+
|
|
40
|
+
// T-REX Smart Contracts
|
|
41
|
+
// The ERC-3643 token suite of the T-REX ecosystem.
|
|
42
|
+
//
|
|
43
|
+
// Copyright (C) 2023, Tokeny sàrl.
|
|
44
|
+
// Copyright (C) 2026 Digital Asset Operational Services ISAC Ltd. ("T-REX Network")
|
|
45
|
+
//
|
|
46
|
+
// This file is part of the T-REX smart contract suite. It derives from the
|
|
47
|
+
// T-REX v4 smart contracts developed by Tokeny sàrl and released under the
|
|
48
|
+
// GNU General Public License v3. All modifications made since then are the
|
|
49
|
+
// work of Digital Asset Operational Services ISAC Ltd. ("T-REX Network").
|
|
50
|
+
//
|
|
51
|
+
// This program is free software: you can redistribute it and/or modify
|
|
52
|
+
// it under the terms of the GNU General Public License as published by
|
|
53
|
+
// the Free Software Foundation, either version 3 of the License, or
|
|
54
|
+
// (at your option) any later version.
|
|
55
|
+
//
|
|
56
|
+
// This program is distributed in the hope that it will be useful,
|
|
57
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
58
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
59
|
+
// GNU General Public License for more details.
|
|
60
|
+
//
|
|
61
|
+
// You should have received a copy of the GNU General Public License
|
|
62
|
+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
63
|
+
|
|
64
|
+
pragma solidity 0.8.30;
|
|
65
|
+
|
|
66
|
+
import { IClaimIssuer } from "@onchain-id/solidity/contracts/interface/IClaimIssuer.sol";
|
|
67
|
+
import { IIdentity } from "@onchain-id/solidity/contracts/interface/IIdentity.sol";
|
|
68
|
+
import { Structs } from "@onchain-id/solidity/contracts/storage/Structs.sol";
|
|
69
|
+
import { LowLevelCall } from "@openzeppelin/contracts/utils/LowLevelCall.sol";
|
|
70
|
+
|
|
71
|
+
import { ERC3643ErrorsLib } from "../ERC3643ErrorsLib.sol";
|
|
72
|
+
import { IERC3643ClaimTopicsRegistry } from "../IERC3643ClaimTopicsRegistry.sol";
|
|
73
|
+
import { IERC3643IdentityRegistry } from "../IERC3643IdentityRegistry.sol";
|
|
74
|
+
import { IERC3643IdentityRegistryStorage } from "../IERC3643IdentityRegistryStorage.sol";
|
|
75
|
+
import { IERC3643TrustedIssuersRegistry } from "../IERC3643TrustedIssuersRegistry.sol";
|
|
76
|
+
|
|
77
|
+
/// @dev Gas given to each trusted issuer's `isClaimValid`. Without a cap an issuer that burns its gas leaves the
|
|
78
|
+
/// loop 1/64 of what remained, too little to ask the next issuer or topic. The heaviest honest check measured
|
|
79
|
+
/// is an ONCHAINID issuer whose claim signer is a WebAuthn (P-256) key verified in Solidity, on a chain without
|
|
80
|
+
/// the P-256 precompile: 314,207 gas, cold, for a claim with a 2,048-byte payload (an ECDSA signer needs
|
|
81
|
+
/// 39,999). The cap leaves room above that for longer client data and gas repricing, and one issuer that burns
|
|
82
|
+
/// it on all 15 topics a registry allows costs 7.5M gas, under half a 16,777,216-gas transaction.
|
|
83
|
+
uint256 constant IS_CLAIM_VALID_GAS = 500_000;
|
|
84
|
+
|
|
85
|
+
/// @dev Asks `trustedIssuer` the encoded `isClaimValid` call with at most `IS_CLAIM_VALID_GAS`, and counts only an
|
|
86
|
+
/// answer of exactly one word equal to true. An issuer that reverts, runs out of its gas, answers nothing or
|
|
87
|
+
/// answers something else reads as an invalid claim, so one broken issuer never halts verification.
|
|
88
|
+
/// Assembly because only it can both cap the gas and copy back just the first word of the answer: a Solidity
|
|
89
|
+
/// call returning `bytes memory` copies the whole answer, so an issuer could make the caller pay for megabytes
|
|
90
|
+
/// of memory, and a typed call in a `try` reverts outside the `catch` when the answer does not decode.
|
|
91
|
+
function issuerConfirmsClaim(address trustedIssuer, bytes memory isClaimValidCall) view returns (bool) {
|
|
92
|
+
bool success;
|
|
93
|
+
bytes32 answer;
|
|
94
|
+
assembly ("memory-safe") {
|
|
95
|
+
success := staticcall(
|
|
96
|
+
IS_CLAIM_VALID_GAS,
|
|
97
|
+
trustedIssuer,
|
|
98
|
+
add(isClaimValidCall, 0x20),
|
|
99
|
+
mload(isClaimValidCall),
|
|
100
|
+
0x00,
|
|
101
|
+
0x20
|
|
102
|
+
)
|
|
103
|
+
answer := mload(0x00)
|
|
104
|
+
}
|
|
105
|
+
return success && LowLevelCall.returnDataSize() == 32 && answer == bytes32(uint256(1));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/// @title ERC3643IdentityRegistry
|
|
109
|
+
/// @dev The ERC-3643 Identity Registry surface and nothing else, over its own ERC-7201 namespace.
|
|
110
|
+
/// Collaborators are reached through `_identityStorage`, `_issuersRegistry` and `_topicsRegistry`, so a
|
|
111
|
+
/// registry serving all three surfaces overrides them to return itself. `_isVerified` is written against
|
|
112
|
+
/// `_requiredClaimTopics` and `_trustedIssuersForTopic`, so extensions can change which topics and
|
|
113
|
+
/// issuers apply without rewriting the claim loop.
|
|
114
|
+
abstract contract ERC3643IdentityRegistry is IERC3643IdentityRegistry {
|
|
115
|
+
|
|
116
|
+
/// @custom:storage-location erc7201:erc3643.storage.IdentityRegistry
|
|
117
|
+
struct ERC3643IdentityRegistryStorage {
|
|
118
|
+
IERC3643IdentityRegistryStorage identityStorage;
|
|
119
|
+
IERC3643TrustedIssuersRegistry issuersRegistry;
|
|
120
|
+
IERC3643ClaimTopicsRegistry topicsRegistry;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// keccak256(abi.encode(uint256(keccak256("erc3643.storage.IdentityRegistry")) - 1)) & ~bytes32(uint256(0xff));
|
|
124
|
+
bytes32 private constant IDENTITY_REGISTRY_STORAGE_LOCATION =
|
|
125
|
+
0x7677ac510b853691f250873636359d7d7673c26ecc94050f9c8f5810c4b61e00;
|
|
126
|
+
|
|
127
|
+
/// @inheritdoc IERC3643IdentityRegistry
|
|
128
|
+
function setIdentityRegistryStorage(address _identityRegistryStorage) external virtual {
|
|
129
|
+
_authorizeRegistryUpdate(_identityRegistryStorage);
|
|
130
|
+
_setIdentityRegistryStorage(_identityRegistryStorage);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/// @inheritdoc IERC3643IdentityRegistry
|
|
134
|
+
function setClaimTopicsRegistry(address _claimTopicsRegistry) external virtual {
|
|
135
|
+
_authorizeRegistryUpdate(_claimTopicsRegistry);
|
|
136
|
+
_setClaimTopicsRegistry(_claimTopicsRegistry);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/// @inheritdoc IERC3643IdentityRegistry
|
|
140
|
+
function setTrustedIssuersRegistry(address _trustedIssuersRegistry) external virtual {
|
|
141
|
+
_authorizeRegistryUpdate(_trustedIssuersRegistry);
|
|
142
|
+
_setTrustedIssuersRegistry(_trustedIssuersRegistry);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/// @inheritdoc IERC3643IdentityRegistry
|
|
146
|
+
function registerIdentity(address _userAddress, IIdentity _identity, uint16 _country) external virtual {
|
|
147
|
+
_authorizeIdentityUpdate(this.registerIdentity.selector);
|
|
148
|
+
_registerIdentity(_userAddress, _identity, _country);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/// @inheritdoc IERC3643IdentityRegistry
|
|
152
|
+
function deleteIdentity(address _userAddress) external virtual {
|
|
153
|
+
_authorizeIdentityUpdate(this.deleteIdentity.selector);
|
|
154
|
+
_deleteIdentity(_userAddress);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/// @inheritdoc IERC3643IdentityRegistry
|
|
158
|
+
function updateCountry(address _userAddress, uint16 _country) external virtual {
|
|
159
|
+
_authorizeIdentityUpdate(this.updateCountry.selector);
|
|
160
|
+
_updateCountry(_userAddress, _country);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/// @inheritdoc IERC3643IdentityRegistry
|
|
164
|
+
function updateIdentity(address _userAddress, IIdentity _identity) external virtual {
|
|
165
|
+
_authorizeIdentityUpdate(this.updateIdentity.selector);
|
|
166
|
+
_updateIdentity(_userAddress, _identity);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/// @inheritdoc IERC3643IdentityRegistry
|
|
170
|
+
function batchRegisterIdentity(
|
|
171
|
+
address[] calldata _userAddresses,
|
|
172
|
+
IIdentity[] calldata _identities,
|
|
173
|
+
uint16[] calldata _countries
|
|
174
|
+
) external virtual {
|
|
175
|
+
_authorizeIdentityUpdate(this.registerIdentity.selector);
|
|
176
|
+
require(
|
|
177
|
+
_userAddresses.length == _identities.length && _userAddresses.length == _countries.length,
|
|
178
|
+
ERC3643ErrorsLib.ArrayLengthMismatch()
|
|
179
|
+
);
|
|
180
|
+
for (uint256 i = 0; i < _userAddresses.length; i++) {
|
|
181
|
+
_registerIdentity(_userAddresses[i], _identities[i], _countries[i]);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/// @inheritdoc IERC3643IdentityRegistry
|
|
186
|
+
function contains(address _userAddress) external view virtual returns (bool) {
|
|
187
|
+
return address(_identityOf(_userAddress)) != address(0);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/// @inheritdoc IERC3643IdentityRegistry
|
|
191
|
+
function isVerified(address _userAddress) external view virtual returns (bool) {
|
|
192
|
+
return _isVerified(_userAddress);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/// @inheritdoc IERC3643IdentityRegistry
|
|
196
|
+
function identity(address _userAddress) external view virtual returns (IIdentity) {
|
|
197
|
+
return _identityOf(_userAddress);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/// @inheritdoc IERC3643IdentityRegistry
|
|
201
|
+
function investorCountry(address _userAddress) external view virtual returns (uint16) {
|
|
202
|
+
return _investorCountry(_userAddress);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/// @inheritdoc IERC3643IdentityRegistry
|
|
206
|
+
function identityStorage() external view virtual returns (IERC3643IdentityRegistryStorage) {
|
|
207
|
+
return _identityStorage();
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/// @inheritdoc IERC3643IdentityRegistry
|
|
211
|
+
function issuersRegistry() external view virtual returns (IERC3643TrustedIssuersRegistry) {
|
|
212
|
+
return _issuersRegistry();
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/// @inheritdoc IERC3643IdentityRegistry
|
|
216
|
+
function topicsRegistry() external view virtual returns (IERC3643ClaimTopicsRegistry) {
|
|
217
|
+
return _topicsRegistry();
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/// @dev Reverts unless `_msgSender()` may call `selector`. `batchRegisterIdentity` passes
|
|
221
|
+
/// `registerIdentity`. Left abstract: the standard defines no access model.
|
|
222
|
+
function _authorizeIdentityUpdate(bytes4 selector) internal virtual;
|
|
223
|
+
|
|
224
|
+
/// @dev Authorization hook for the three collaborator setters. Receives the new address so derived
|
|
225
|
+
/// contracts can apply per-target checks (interface support, a shared authority).
|
|
226
|
+
function _authorizeRegistryUpdate(address newRegistry) internal virtual;
|
|
227
|
+
|
|
228
|
+
/// @dev Points this registry at a new identity storage.
|
|
229
|
+
function _setIdentityRegistryStorage(address identityRegistryStorage) internal virtual {
|
|
230
|
+
require(identityRegistryStorage != address(0), ERC3643ErrorsLib.ZeroAddress());
|
|
231
|
+
_erc3643IdentityRegistryStorage().identityStorage = IERC3643IdentityRegistryStorage(identityRegistryStorage);
|
|
232
|
+
emit IdentityStorageSet(identityRegistryStorage);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/// @dev Points this registry at a new claim topics registry.
|
|
236
|
+
function _setClaimTopicsRegistry(address claimTopicsRegistry) internal virtual {
|
|
237
|
+
require(claimTopicsRegistry != address(0), ERC3643ErrorsLib.ZeroAddress());
|
|
238
|
+
_erc3643IdentityRegistryStorage().topicsRegistry = IERC3643ClaimTopicsRegistry(claimTopicsRegistry);
|
|
239
|
+
emit ClaimTopicsRegistrySet(claimTopicsRegistry);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/// @dev Points this registry at a new trusted issuers registry.
|
|
243
|
+
function _setTrustedIssuersRegistry(address trustedIssuersRegistry) internal virtual {
|
|
244
|
+
require(trustedIssuersRegistry != address(0), ERC3643ErrorsLib.ZeroAddress());
|
|
245
|
+
_erc3643IdentityRegistryStorage().issuersRegistry = IERC3643TrustedIssuersRegistry(trustedIssuersRegistry);
|
|
246
|
+
emit TrustedIssuersRegistrySet(trustedIssuersRegistry);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/// @dev Registers an identity through the identity storage.
|
|
250
|
+
function _registerIdentity(address userAddress, IIdentity userIdentity, uint16 country) internal virtual {
|
|
251
|
+
_identityStorage().addIdentityToStorage(userAddress, userIdentity, country);
|
|
252
|
+
emit IdentityRegistered(userAddress, userIdentity);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/// @dev Removes an identity through the identity storage.
|
|
256
|
+
function _deleteIdentity(address userAddress) internal virtual {
|
|
257
|
+
IIdentity oldIdentity = _identityOf(userAddress);
|
|
258
|
+
_identityStorage().removeIdentityFromStorage(userAddress);
|
|
259
|
+
emit IdentityRemoved(userAddress, oldIdentity);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/// @dev Updates an investor's country through the identity storage.
|
|
263
|
+
function _updateCountry(address userAddress, uint16 country) internal virtual {
|
|
264
|
+
_identityStorage().modifyStoredInvestorCountry(userAddress, country);
|
|
265
|
+
emit CountryUpdated(userAddress, country);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/// @dev Replaces an investor's identity contract through the identity storage.
|
|
269
|
+
function _updateIdentity(address userAddress, IIdentity userIdentity) internal virtual {
|
|
270
|
+
IIdentity oldIdentity = _identityOf(userAddress);
|
|
271
|
+
_identityStorage().modifyStoredIdentity(userAddress, userIdentity);
|
|
272
|
+
emit IdentityUpdated(oldIdentity, userIdentity);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/// @dev Whether `userAddress` holds a valid claim, from a trusted issuer, for every required topic.
|
|
276
|
+
///
|
|
277
|
+
/// An identity answers `getClaim`, so the issuer it returns is untrusted input: only a claim from
|
|
278
|
+
/// `trustedIssuer` hashes to `claimId`. Validity is therefore asked of the configured issuer, never
|
|
279
|
+
/// of the address the identity supplied. The call is made with a bounded low-level staticcall so a
|
|
280
|
+
/// hostile or broken issuer cannot halt verification by reverting, burning its gas or returning
|
|
281
|
+
/// oversized data.
|
|
282
|
+
function _isVerified(address userAddress) internal view virtual returns (bool) {
|
|
283
|
+
IIdentity userIdentity = _activeIdentityOf(userAddress);
|
|
284
|
+
if (address(userIdentity) == address(0)) return false;
|
|
285
|
+
|
|
286
|
+
uint256[] memory requiredClaimTopics = _requiredClaimTopics(userIdentity);
|
|
287
|
+
if (requiredClaimTopics.length == 0) return true;
|
|
288
|
+
|
|
289
|
+
for (uint256 i = 0; i < requiredClaimTopics.length; i++) {
|
|
290
|
+
if (!_hasValidClaimForTopic(userIdentity, requiredClaimTopics[i])) return false;
|
|
291
|
+
}
|
|
292
|
+
return true;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/// @dev Whether `userIdentity` holds a valid claim for `claimTopic` from any issuer trusted for it.
|
|
296
|
+
///
|
|
297
|
+
/// Each claim is read whole through `getClaim`, the only claim getter ONCHAINID exposes, so the identity loads
|
|
298
|
+
/// the signature, payload and uri (up to 2,048 bytes each) before the issuer can say the claim has expired. No
|
|
299
|
+
/// change here can skip that load: an expired claim of that size costs about 450,000 gas inside `getClaim`
|
|
300
|
+
/// alone, so about 30 of them from issuers trusted ahead of the valid one exceed a 16,777,216-gas transaction
|
|
301
|
+
/// and transfers to the holder revert. The holder recovers by removing the stale claims.
|
|
302
|
+
function _hasValidClaimForTopic(IIdentity userIdentity, uint256 claimTopic) internal view virtual returns (bool) {
|
|
303
|
+
address[] memory trustedIssuersForTopic = _trustedIssuersForTopic(claimTopic);
|
|
304
|
+
if (trustedIssuersForTopic.length == 0) return false;
|
|
305
|
+
|
|
306
|
+
for (uint256 j = 0; j < trustedIssuersForTopic.length; j++) {
|
|
307
|
+
address trustedIssuer = trustedIssuersForTopic[j];
|
|
308
|
+
bytes32 claimId = keccak256(abi.encode(trustedIssuer, claimTopic));
|
|
309
|
+
(uint256 foundClaimTopic,, address issuer, bytes memory sig, Structs.ClaimData memory data,) =
|
|
310
|
+
userIdentity.getClaim(claimId);
|
|
311
|
+
|
|
312
|
+
if (foundClaimTopic != claimTopic || issuer != trustedIssuer) continue;
|
|
313
|
+
|
|
314
|
+
bytes memory isClaimValidCall =
|
|
315
|
+
abi.encodeCall(IClaimIssuer.isClaimValid, (userIdentity, claimTopic, sig, data));
|
|
316
|
+
if (issuerConfirmsClaim(trustedIssuer, isClaimValidCall)) return true;
|
|
317
|
+
}
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/// @dev The claim topics `userIdentity` must satisfy. Defaults to the configured topics registry.
|
|
322
|
+
/// Extensions override this to vary the requirement (per identity type, for instance) without
|
|
323
|
+
/// reimplementing the verification loop.
|
|
324
|
+
function _requiredClaimTopics(
|
|
325
|
+
IIdentity /* userIdentity */
|
|
326
|
+
)
|
|
327
|
+
internal
|
|
328
|
+
view
|
|
329
|
+
virtual
|
|
330
|
+
returns (uint256[] memory)
|
|
331
|
+
{
|
|
332
|
+
return _topicsRegistry().getClaimTopics();
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/// @dev The issuers trusted for `claimTopic`. Defaults to the configured issuers registry.
|
|
336
|
+
function _trustedIssuersForTopic(uint256 claimTopic) internal view virtual returns (address[] memory) {
|
|
337
|
+
return _issuersRegistry().getTrustedIssuersForClaimTopic(claimTopic);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/// @dev The identity of a wallet, read through the identity storage. This is the attribution read
|
|
341
|
+
/// behind `contains` and `identity`: it answers who owns what the wallet holds.
|
|
342
|
+
function _identityOf(address userAddress) internal view virtual returns (IIdentity) {
|
|
343
|
+
return _identityStorage().storedIdentity(userAddress);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/// @dev The identity a wallet may act through, or zero when it may not. This is the admission read
|
|
347
|
+
/// behind `isVerified`: it is kept apart from `_identityOf` so an extension can deny new activity to a
|
|
348
|
+
/// wallet (a revoked one, for instance) while `contains` and `identity` keep attributing its holdings.
|
|
349
|
+
/// Defaults to `_identityOf`.
|
|
350
|
+
function _activeIdentityOf(address userAddress) internal view virtual returns (IIdentity) {
|
|
351
|
+
return _identityOf(userAddress);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/// @dev The country of a wallet, read through the identity storage.
|
|
355
|
+
function _investorCountry(address userAddress) internal view virtual returns (uint16) {
|
|
356
|
+
return _identityStorage().storedInvestorCountry(userAddress);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/// @dev The identity storage this registry writes through.
|
|
360
|
+
function _identityStorage() internal view virtual returns (IERC3643IdentityRegistryStorage) {
|
|
361
|
+
return _erc3643IdentityRegistryStorage().identityStorage;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/// @dev The trusted issuers registry backing verification. A consolidated registry overrides this
|
|
365
|
+
/// to return itself.
|
|
366
|
+
function _issuersRegistry() internal view virtual returns (IERC3643TrustedIssuersRegistry) {
|
|
367
|
+
return _erc3643IdentityRegistryStorage().issuersRegistry;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/// @dev The claim topics registry backing verification. A consolidated registry overrides this
|
|
371
|
+
/// to return itself.
|
|
372
|
+
function _topicsRegistry() internal view virtual returns (IERC3643ClaimTopicsRegistry) {
|
|
373
|
+
return _erc3643IdentityRegistryStorage().topicsRegistry;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
function _erc3643IdentityRegistryStorage() internal pure returns (ERC3643IdentityRegistryStorage storage s) {
|
|
377
|
+
assembly ("memory-safe") {
|
|
378
|
+
s.slot := IDENTITY_REGISTRY_STORAGE_LOCATION
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
}
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0
|
|
2
|
+
//
|
|
3
|
+
// :+#####%%%%%%%%%%%%%%+
|
|
4
|
+
// .-*@@@%+.:+%@@@@@%%#***%@@%=
|
|
5
|
+
// :=*%@@@#=. :#@@% *@@@%=
|
|
6
|
+
// .-+*%@%*-.:+%@@@@@@+. -*+: .=#. :%@@@%-
|
|
7
|
+
// :=*@@@@%%@@@@@@@@@%@@@- .=#@@@%@%= =@@@@#.
|
|
8
|
+
// -=+#%@@%#*=:. :%@@@@%. -*@@#*@@@@@@@#=:- *@@@@+
|
|
9
|
+
// =@@%=:. :=: *@@@@@%#- =%*%@@@@#+-. =+ :%@@@%-
|
|
10
|
+
// -@@%. .+@@@ =+=-. @@#- +@@@%- =@@@@%:
|
|
11
|
+
// :@@@. .+@@#%: : .=*=-::.-%@@@+*@@= +@@@@#.
|
|
12
|
+
// %@@: +@%%* =%@@@@@@@@@@@#. .*@%- +@@@@*.
|
|
13
|
+
// #@@= .+@@@@%:=*@@@@@- :%@%: .*@@@@+
|
|
14
|
+
// *@@* +@@@#-@@%-:%@@* +@@#. :%@@@@-
|
|
15
|
+
// -@@% .:-=++*##%%%@@@@@@@@@@@@*. :@+.@@@%: .#@@+ =@@@@#:
|
|
16
|
+
// .@@@*-+*#%%%@@@@@@@@@@@@@@@@%%#**@@%@@@. *@=*@@# :#@%= .#@@@@#-
|
|
17
|
+
// -%@@@@@@@@@@@@@@@*+==-:-@@@= *@# .#@*-=*@@@@%= -%@@@* =@@@@@%-
|
|
18
|
+
// -+%@@@#. %@%%= -@@:+@: -@@* *@@*-:: -%@@%=. .*@@@@@#
|
|
19
|
+
// *@@@* +@* *@@##@@- #@*@@+ -@@= . :+@@@#: .-+@@@%+-
|
|
20
|
+
// +@@@%*@@:..=@@@@* .@@@* .#@#. .=+- .=%@@@*. :+#@@@@*=:
|
|
21
|
+
// =@@@@%@@@@@@@@@@@@@@@@@@@@@@%- :+#*. :*@@@%=. .=#@@@@%+:
|
|
22
|
+
// .%@@= ..... .=#@@+. .#@@@*: -*%@@@@%+.
|
|
23
|
+
// +@@#+===---:::... .=%@@*- +@@@+. -*@@@@@%+.
|
|
24
|
+
// -@@@@@@@@@@@@@@@@@@@@@@%@@@@= -@@@+ -#@@@@@#=.
|
|
25
|
+
// ..:::---===+++***###%%%@@@#- .#@@+ -*@@@@@#=.
|
|
26
|
+
// @@@@@@+. +@@*. .+@@@@@%=.
|
|
27
|
+
// -@@@@@= =@@%: -#@@@@%+.
|
|
28
|
+
// +@@@@@. =@@@= .+@@@@@*:
|
|
29
|
+
// #@@@@#:%@@#. :*@@@@#-
|
|
30
|
+
// @@@@@%@@@= :#@@@@+.
|
|
31
|
+
// :@@@@@@@#.:#@@@%-
|
|
32
|
+
// +@@@@@@-.*@@@*:
|
|
33
|
+
// #@@@@#.=@@@+.
|
|
34
|
+
// @@@@+-%@%=
|
|
35
|
+
// :@@@#%@%=
|
|
36
|
+
// +@@@@%-
|
|
37
|
+
// :#%%=
|
|
38
|
+
//
|
|
39
|
+
|
|
40
|
+
// T-REX Smart Contracts
|
|
41
|
+
// The ERC-3643 token suite of the T-REX ecosystem.
|
|
42
|
+
//
|
|
43
|
+
// Copyright (C) 2023, Tokeny sàrl.
|
|
44
|
+
// Copyright (C) 2026 Digital Asset Operational Services ISAC Ltd. ("T-REX Network")
|
|
45
|
+
//
|
|
46
|
+
// This file is part of the T-REX smart contract suite. It derives from the
|
|
47
|
+
// T-REX v4 smart contracts developed by Tokeny sàrl and released under the
|
|
48
|
+
// GNU General Public License v3. All modifications made since then are the
|
|
49
|
+
// work of Digital Asset Operational Services ISAC Ltd. ("T-REX Network").
|
|
50
|
+
//
|
|
51
|
+
// This program is free software: you can redistribute it and/or modify
|
|
52
|
+
// it under the terms of the GNU General Public License as published by
|
|
53
|
+
// the Free Software Foundation, either version 3 of the License, or
|
|
54
|
+
// (at your option) any later version.
|
|
55
|
+
//
|
|
56
|
+
// This program is distributed in the hope that it will be useful,
|
|
57
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
58
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
59
|
+
// GNU General Public License for more details.
|
|
60
|
+
//
|
|
61
|
+
// You should have received a copy of the GNU General Public License
|
|
62
|
+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
63
|
+
|
|
64
|
+
pragma solidity 0.8.30;
|
|
65
|
+
|
|
66
|
+
import { IIdentity } from "@onchain-id/solidity/contracts/interface/IIdentity.sol";
|
|
67
|
+
import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
|
68
|
+
|
|
69
|
+
import { ERC3643ErrorsLib } from "../ERC3643ErrorsLib.sol";
|
|
70
|
+
import { IERC3643IdentityRegistryStorage } from "../IERC3643IdentityRegistryStorage.sol";
|
|
71
|
+
|
|
72
|
+
/// @title ERC3643IdentityRegistryStorage
|
|
73
|
+
/// @dev The ERC-3643 Identity Registry Storage surface and nothing else, over its own ERC-7201
|
|
74
|
+
/// namespace. Binding has its own authorization hook, separate from identity writes, because
|
|
75
|
+
/// deployments govern the two differently.
|
|
76
|
+
abstract contract ERC3643IdentityRegistryStorage is IERC3643IdentityRegistryStorage {
|
|
77
|
+
|
|
78
|
+
using EnumerableSet for EnumerableSet.AddressSet;
|
|
79
|
+
|
|
80
|
+
/// @dev Cap so enumerating the bound set stays affordable.
|
|
81
|
+
uint256 internal constant MAX_IDENTITY_REGISTRIES = 300;
|
|
82
|
+
|
|
83
|
+
struct StoredIdentity {
|
|
84
|
+
IIdentity identityContract;
|
|
85
|
+
uint16 investorCountry;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/// @custom:storage-location erc7201:erc3643.storage.IdentityRegistryStorage
|
|
89
|
+
struct ERC3643IdentityRegistryStorageStorage {
|
|
90
|
+
mapping(address user => StoredIdentity) identities;
|
|
91
|
+
|
|
92
|
+
EnumerableSet.AddressSet identityRegistries;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// keccak256(abi.encode(uint256(keccak256("erc3643.storage.IdentityRegistryStorage")) - 1)) & ~bytes32(uint256(0xff));
|
|
96
|
+
bytes32 private constant IDENTITY_REGISTRY_STORAGE_STORAGE_LOCATION =
|
|
97
|
+
0x8e8aa323647c3f2580137bf922482bdf62534082dec9617ddb5e7739bad03900;
|
|
98
|
+
|
|
99
|
+
/// @inheritdoc IERC3643IdentityRegistryStorage
|
|
100
|
+
function addIdentityToStorage(address _userAddress, IIdentity _identity, uint16 _country) external virtual {
|
|
101
|
+
_authorizeIdentityWrite();
|
|
102
|
+
_addIdentityToStorage(_userAddress, _identity, _country);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/// @inheritdoc IERC3643IdentityRegistryStorage
|
|
106
|
+
function modifyStoredIdentity(address _userAddress, IIdentity _identity) external virtual {
|
|
107
|
+
_authorizeIdentityWrite();
|
|
108
|
+
_modifyStoredIdentity(_userAddress, _identity);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/// @inheritdoc IERC3643IdentityRegistryStorage
|
|
112
|
+
function modifyStoredInvestorCountry(address _userAddress, uint16 _country) external virtual {
|
|
113
|
+
_authorizeIdentityWrite();
|
|
114
|
+
_modifyStoredInvestorCountry(_userAddress, _country);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/// @inheritdoc IERC3643IdentityRegistryStorage
|
|
118
|
+
function removeIdentityFromStorage(address _userAddress) external virtual {
|
|
119
|
+
_authorizeIdentityWrite();
|
|
120
|
+
_removeIdentityFromStorage(_userAddress);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/// @inheritdoc IERC3643IdentityRegistryStorage
|
|
124
|
+
function bindIdentityRegistry(address _identityRegistry) external virtual {
|
|
125
|
+
_authorizeRegistryBinding(_identityRegistry);
|
|
126
|
+
_bindIdentityRegistry(_identityRegistry);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/// @inheritdoc IERC3643IdentityRegistryStorage
|
|
130
|
+
function unbindIdentityRegistry(address _identityRegistry) external virtual {
|
|
131
|
+
_authorizeRegistryBinding(_identityRegistry);
|
|
132
|
+
_unbindIdentityRegistry(_identityRegistry);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/// @inheritdoc IERC3643IdentityRegistryStorage
|
|
136
|
+
function linkedIdentityRegistries() external view virtual returns (address[] memory) {
|
|
137
|
+
return _linkedIdentityRegistries();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/// @inheritdoc IERC3643IdentityRegistryStorage
|
|
141
|
+
function linkedIdentityRegistryCount() external view virtual returns (uint256) {
|
|
142
|
+
return _linkedIdentityRegistryCount();
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/// @inheritdoc IERC3643IdentityRegistryStorage
|
|
146
|
+
function linkedIdentityRegistries(uint256 _start, uint256 _end) external view virtual returns (address[] memory) {
|
|
147
|
+
return _linkedIdentityRegistries(_start, _end);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/// @inheritdoc IERC3643IdentityRegistryStorage
|
|
151
|
+
function storedIdentity(address _userAddress) external view virtual returns (IIdentity) {
|
|
152
|
+
return _storedIdentity(_userAddress);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/// @inheritdoc IERC3643IdentityRegistryStorage
|
|
156
|
+
function storedInvestorCountry(address _userAddress) external view virtual returns (uint16) {
|
|
157
|
+
return _storedInvestorCountry(_userAddress);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/// @dev Authorization hook for the identity-writing functions.
|
|
161
|
+
/// Left abstract: the standard defines no access model.
|
|
162
|
+
function _authorizeIdentityWrite() internal virtual;
|
|
163
|
+
|
|
164
|
+
/// @dev Authorization hook for binding and unbinding registries. Receives the registry address so
|
|
165
|
+
/// derived contracts can apply per-target checks (a shared authority, for instance).
|
|
166
|
+
function _authorizeRegistryBinding(address identityRegistry) internal virtual;
|
|
167
|
+
|
|
168
|
+
/// @dev Stores an identity and country for a wallet that has none yet.
|
|
169
|
+
function _addIdentityToStorage(address userAddress, IIdentity userIdentity, uint16 country) internal virtual {
|
|
170
|
+
require(userAddress != address(0) && address(userIdentity) != address(0), ERC3643ErrorsLib.ZeroAddress());
|
|
171
|
+
|
|
172
|
+
ERC3643IdentityRegistryStorageStorage storage s = _erc3643IdentityRegistryStorageStorage();
|
|
173
|
+
require(
|
|
174
|
+
address(s.identities[userAddress].identityContract) == address(0), ERC3643ErrorsLib.AddressAlreadyStored()
|
|
175
|
+
);
|
|
176
|
+
s.identities[userAddress].identityContract = userIdentity;
|
|
177
|
+
emit IdentityStored(userAddress, userIdentity);
|
|
178
|
+
// The standard store event omits the country, so the country is recorded through the same path
|
|
179
|
+
// `modifyStoredInvestorCountry` uses and reported with the same event.
|
|
180
|
+
_setStoredInvestorCountry(userAddress, country);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/// @dev Records a wallet's country and reports it. Separate from the write paths that call it so a
|
|
184
|
+
/// deployment that keeps no country can drop both the write and the event in one override.
|
|
185
|
+
function _setStoredInvestorCountry(address userAddress, uint16 country) internal virtual {
|
|
186
|
+
_erc3643IdentityRegistryStorageStorage().identities[userAddress].investorCountry = country;
|
|
187
|
+
emit CountryModified(userAddress, country);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/// @dev Replaces the identity contract of an already-stored wallet.
|
|
191
|
+
function _modifyStoredIdentity(address userAddress, IIdentity userIdentity) internal virtual {
|
|
192
|
+
require(userAddress != address(0) && address(userIdentity) != address(0), ERC3643ErrorsLib.ZeroAddress());
|
|
193
|
+
ERC3643IdentityRegistryStorageStorage storage s = _erc3643IdentityRegistryStorageStorage();
|
|
194
|
+
IIdentity oldIdentity = s.identities[userAddress].identityContract;
|
|
195
|
+
require(address(oldIdentity) != address(0), ERC3643ErrorsLib.AddressNotYetStored());
|
|
196
|
+
s.identities[userAddress].identityContract = userIdentity;
|
|
197
|
+
emit IdentityModified(oldIdentity, userIdentity);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/// @dev Replaces the country of an already-stored wallet.
|
|
201
|
+
function _modifyStoredInvestorCountry(address userAddress, uint16 country) internal virtual {
|
|
202
|
+
require(userAddress != address(0), ERC3643ErrorsLib.ZeroAddress());
|
|
203
|
+
ERC3643IdentityRegistryStorageStorage storage s = _erc3643IdentityRegistryStorageStorage();
|
|
204
|
+
require(
|
|
205
|
+
address(s.identities[userAddress].identityContract) != address(0), ERC3643ErrorsLib.AddressNotYetStored()
|
|
206
|
+
);
|
|
207
|
+
_setStoredInvestorCountry(userAddress, country);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/// @dev Deletes a wallet's stored identity record.
|
|
211
|
+
function _removeIdentityFromStorage(address userAddress) internal virtual {
|
|
212
|
+
require(userAddress != address(0), ERC3643ErrorsLib.ZeroAddress());
|
|
213
|
+
ERC3643IdentityRegistryStorageStorage storage s = _erc3643IdentityRegistryStorageStorage();
|
|
214
|
+
IIdentity oldIdentity = s.identities[userAddress].identityContract;
|
|
215
|
+
require(address(oldIdentity) != address(0), ERC3643ErrorsLib.AddressNotYetStored());
|
|
216
|
+
delete s.identities[userAddress];
|
|
217
|
+
emit IdentityUnstored(userAddress, oldIdentity);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/// @dev Adds a registry to the bound set. Callers are responsible for rejecting the zero address.
|
|
221
|
+
function _bindIdentityRegistry(address identityRegistry) internal virtual {
|
|
222
|
+
ERC3643IdentityRegistryStorageStorage storage s = _erc3643IdentityRegistryStorageStorage();
|
|
223
|
+
require(
|
|
224
|
+
s.identityRegistries.length() < MAX_IDENTITY_REGISTRIES,
|
|
225
|
+
ERC3643ErrorsLib.MaxIRByIRSReached(MAX_IDENTITY_REGISTRIES)
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
// Rebinding an already-bound registry changes nothing, so it stays silent.
|
|
229
|
+
if (s.identityRegistries.add(identityRegistry)) {
|
|
230
|
+
emit IdentityRegistryBound(identityRegistry);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/// @dev Removes a registry from the bound set.
|
|
235
|
+
function _unbindIdentityRegistry(address identityRegistry) internal virtual {
|
|
236
|
+
require(identityRegistry != address(0), ERC3643ErrorsLib.ZeroAddress());
|
|
237
|
+
ERC3643IdentityRegistryStorageStorage storage s = _erc3643IdentityRegistryStorageStorage();
|
|
238
|
+
require(s.identityRegistries.remove(identityRegistry), ERC3643ErrorsLib.IdentityRegistryNotStored());
|
|
239
|
+
|
|
240
|
+
emit IdentityRegistryUnbound(identityRegistry);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/// @dev Reads the bound registries, separate from the external getter so derived contracts can
|
|
244
|
+
/// consult them without an external call.
|
|
245
|
+
function _linkedIdentityRegistries() internal view virtual returns (address[] memory) {
|
|
246
|
+
return _erc3643IdentityRegistryStorageStorage().identityRegistries.values();
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/// @dev Reads a slice of the bound registries, separate from the external getter so derived contracts
|
|
250
|
+
/// can consult them without an external call. Bounds are clamped by the underlying set, so an
|
|
251
|
+
/// out-of-range page yields an empty array.
|
|
252
|
+
function _linkedIdentityRegistries(uint256 start, uint256 end) internal view virtual returns (address[] memory) {
|
|
253
|
+
return _erc3643IdentityRegistryStorageStorage().identityRegistries.values(start, end);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/// @dev Tests membership in the bound set, separate from the external getter so derived contracts
|
|
257
|
+
/// can consult it without an external call. Enumeration only, never an authorization check: the
|
|
258
|
+
/// bound set does not gate writes to this storage.
|
|
259
|
+
function _isIdentityRegistryBound(address identityRegistry) internal view virtual returns (bool) {
|
|
260
|
+
return _erc3643IdentityRegistryStorageStorage().identityRegistries.contains(identityRegistry);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/// @dev Reads the size of the bound set without copying it, separate from the external getter so
|
|
264
|
+
/// derived contracts can consult it without an external call.
|
|
265
|
+
function _linkedIdentityRegistryCount() internal view virtual returns (uint256) {
|
|
266
|
+
return _erc3643IdentityRegistryStorageStorage().identityRegistries.length();
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/// @dev Reads the stored identity of a wallet, separate from the external getter so derived
|
|
270
|
+
/// contracts can consult the standard record without re-entering their own overridden view.
|
|
271
|
+
function _storedIdentity(address userAddress) internal view virtual returns (IIdentity) {
|
|
272
|
+
return _erc3643IdentityRegistryStorageStorage().identities[userAddress].identityContract;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/// @dev Reads the stored country of a wallet.
|
|
276
|
+
function _storedInvestorCountry(address userAddress) internal view virtual returns (uint16) {
|
|
277
|
+
return _erc3643IdentityRegistryStorageStorage().identities[userAddress].investorCountry;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
function _erc3643IdentityRegistryStorageStorage()
|
|
281
|
+
internal
|
|
282
|
+
pure
|
|
283
|
+
returns (ERC3643IdentityRegistryStorageStorage storage s)
|
|
284
|
+
{
|
|
285
|
+
assembly ("memory-safe") {
|
|
286
|
+
s.slot := IDENTITY_REGISTRY_STORAGE_STORAGE_LOCATION
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
}
|