@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
|
@@ -36,188 +36,163 @@
|
|
|
36
36
|
// +@@@@%-
|
|
37
37
|
// :#%%=
|
|
38
38
|
//
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
* You should have received a copy of the GNU General Public License
|
|
60
|
-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
61
|
-
*/
|
|
39
|
+
|
|
40
|
+
// T-REX Smart Contracts
|
|
41
|
+
// The ERC-3643 token suite of the T-REX ecosystem.
|
|
42
|
+
//
|
|
43
|
+
// Copyright (C) 2026 Digital Asset Operational Services ISAC Ltd. ("T-REX Network")
|
|
44
|
+
//
|
|
45
|
+
// This file is part of the T-REX smart contract suite.
|
|
46
|
+
//
|
|
47
|
+
// This program is free software: you can redistribute it and/or modify
|
|
48
|
+
// it under the terms of the GNU General Public License as published by
|
|
49
|
+
// the Free Software Foundation, either version 3 of the License, or
|
|
50
|
+
// (at your option) any later version.
|
|
51
|
+
//
|
|
52
|
+
// This program is distributed in the hope that it will be useful,
|
|
53
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
54
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
55
|
+
// GNU General Public License for more details.
|
|
56
|
+
//
|
|
57
|
+
// You should have received a copy of the GNU General Public License
|
|
58
|
+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
62
59
|
|
|
63
60
|
pragma solidity 0.8.30;
|
|
64
61
|
|
|
65
|
-
import {
|
|
66
|
-
import {
|
|
62
|
+
import { AuthorityUtils } from "@openzeppelin/contracts/access/manager/AuthorityUtils.sol";
|
|
63
|
+
import { IAccessManager } from "@openzeppelin/contracts/access/manager/IAccessManager.sol";
|
|
64
|
+
import { InteroperableAddress } from "@openzeppelin/contracts/utils/draft-InteroperableAddress.sol";
|
|
67
65
|
import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
|
68
66
|
|
|
69
|
-
import {
|
|
67
|
+
import { IERC3643 } from "../../ERC-3643/IERC3643.sol";
|
|
70
68
|
import { IERC3643Compliance } from "../../ERC-3643/IERC3643Compliance.sol";
|
|
69
|
+
import { ERC3643Compliance } from "../../ERC-3643/base/ERC3643Compliance.sol";
|
|
70
|
+
import { ISettlementHandler } from "../../interop/ISettlementHandler.sol";
|
|
71
71
|
import { ErrorsLib } from "../../libraries/ErrorsLib.sol";
|
|
72
72
|
import { EventsLib } from "../../libraries/EventsLib.sol";
|
|
73
|
-
import {
|
|
73
|
+
import { MessageTypesLib } from "../../libraries/MessageTypesLib.sol";
|
|
74
|
+
import { WalletKeyLib } from "../../libraries/WalletKeyLib.sol";
|
|
75
|
+
import { ITREXRegistry } from "../../registry/interface/ITREXRegistry.sol";
|
|
76
|
+
import { IToken } from "../../token/IToken.sol";
|
|
77
|
+
import { AccessManagedOwnableUpgradeable } from "../../utils/AccessManagedOwnableUpgradeable.sol";
|
|
78
|
+
import { IComplianceLedger } from "./IComplianceLedger.sol";
|
|
74
79
|
import { IModularCompliance } from "./IModularCompliance.sol";
|
|
80
|
+
import { ITransferValidation } from "./ITransferValidation.sol";
|
|
81
|
+
import { ModuleSetLib } from "./ModuleSetLib.sol";
|
|
82
|
+
import { MovementKindLib } from "./MovementKindLib.sol";
|
|
83
|
+
import { TransferContextLib } from "./TransferContextLib.sol";
|
|
84
|
+
import { TransferValidation } from "./TransferValidation.sol";
|
|
75
85
|
import { IModule } from "./modules/IModule.sol";
|
|
76
86
|
|
|
77
|
-
|
|
87
|
+
/// @title ModularCompliance
|
|
88
|
+
/// @dev {ERC3643Compliance} plus the module system that supplies the rules: the bound modules sorted by what
|
|
89
|
+
/// they are, the dispatch implementing the base hooks over the ledger, the `canSpenderCall` check, the
|
|
90
|
+
/// cross-chain validation lifecycle of {TransferValidation} and AccessManager authorization.
|
|
91
|
+
///
|
|
92
|
+
/// Every module reads the same numbers. On a movement the compliance resolves both identities once, asks every
|
|
93
|
+
/// `RULE` module the largest amount it allows and keeps the smallest answer, moves the positions, then tells
|
|
94
|
+
/// every `TRACKER` module what happened. A mint and a burn are the same movement with one side missing, so the
|
|
95
|
+
/// three base hooks differ only in which side they fill in. A module is kept in one list per type it named at
|
|
96
|
+
/// binding, so a dispatch is a plain loop over the modules concerned and nothing else.
|
|
97
|
+
contract ModularCompliance is
|
|
98
|
+
IModularCompliance,
|
|
99
|
+
ISettlementHandler,
|
|
100
|
+
ERC3643Compliance,
|
|
101
|
+
TransferValidation,
|
|
102
|
+
AccessManagedOwnableUpgradeable
|
|
103
|
+
{
|
|
78
104
|
|
|
79
105
|
using EnumerableSet for EnumerableSet.AddressSet;
|
|
80
106
|
|
|
81
|
-
/// @
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
EnumerableSet.AddressSet modules;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// keccak256(abi.encode(uint256(keccak256("ERC3643.storage.ModularCompliance")) - 1)) & ~bytes32(uint256(0xff));
|
|
90
|
-
bytes32 private constant STORAGE_LOCATION = 0x44b49c37d3109105ef492022bec834e94dca859d191a0d5323d3afbc4aa69400;
|
|
91
|
-
|
|
92
|
-
/// modifiers
|
|
93
|
-
/**
|
|
94
|
-
* @dev Throws if called by any address that is not a token bound to the compliance.
|
|
95
|
-
*/
|
|
96
|
-
modifier onlyBoundedToken() {
|
|
97
|
-
require(msg.sender == _getStorage().tokenBound, ErrorsLib.AddressNotATokenBoundToComplianceContract());
|
|
98
|
-
_;
|
|
99
|
-
}
|
|
107
|
+
/// @dev The caller of the `transferFrom` the token is running. The ERC-3643 hooks carry no spender, so
|
|
108
|
+
/// {canSpenderCall}, which the token asks right before that transfer moves anything, writes it here for
|
|
109
|
+
/// the rules and trackers of the same transfer, and {_applyMovement} forgets it. Transient: it never
|
|
110
|
+
/// outlives the transaction and takes no storage slot.
|
|
111
|
+
address private transient _transferFromSpender;
|
|
100
112
|
|
|
101
113
|
constructor() {
|
|
102
114
|
_disableInitializers();
|
|
103
115
|
}
|
|
104
116
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
* not accepted
|
|
115
|
-
* emits a `TokenBound` event
|
|
116
|
-
* emits a `ModuleAdded` event for each module
|
|
117
|
-
* emits a `ModuleInteraction` event for each `_moduleSettings[i]` applied
|
|
118
|
-
*/
|
|
119
|
-
function init(address _token, address _owner, address[] calldata _modules, bytes[] calldata _moduleSettings)
|
|
120
|
-
external
|
|
121
|
-
initializer
|
|
122
|
-
{
|
|
123
|
-
require(_token != address(0) && _owner != address(0), ErrorsLib.ZeroAddress());
|
|
124
|
-
require(_modules.length >= _moduleSettings.length, ErrorsLib.InvalidCompliancePattern());
|
|
125
|
-
require(_modules.length <= 25, ErrorsLib.MaxModulesReached(25));
|
|
117
|
+
function init(
|
|
118
|
+
address tokenAddress,
|
|
119
|
+
address accessManagerAddress,
|
|
120
|
+
address[] calldata modules,
|
|
121
|
+
bytes[] calldata moduleSettings
|
|
122
|
+
) external initializer {
|
|
123
|
+
// `_bindToken` refuses a zero token with the same error, so only the manager is checked here.
|
|
124
|
+
require(accessManagerAddress != address(0), ErrorsLib.ZeroAddress());
|
|
125
|
+
require(modules.length >= moduleSettings.length, ErrorsLib.InvalidCompliancePattern());
|
|
126
126
|
|
|
127
|
-
|
|
128
|
-
_bindToken(_token);
|
|
127
|
+
__AccessManaged_init(accessManagerAddress);
|
|
129
128
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
if (i <
|
|
135
|
-
_callModuleFunction(
|
|
129
|
+
_bindToken(tokenAddress);
|
|
130
|
+
|
|
131
|
+
for (uint256 i = 0; i < modules.length; i++) {
|
|
132
|
+
_addModule(modules[i]);
|
|
133
|
+
if (i < moduleSettings.length) {
|
|
134
|
+
_callModuleFunction(moduleSettings[i], modules[i]);
|
|
136
135
|
}
|
|
137
136
|
}
|
|
138
137
|
}
|
|
139
138
|
|
|
140
|
-
/**
|
|
141
|
-
* @dev See {IERC3643Compliance-bindToken}.
|
|
142
|
-
*/
|
|
143
|
-
function bindToken(address _token) external override {
|
|
144
|
-
Storage storage s = _getStorage();
|
|
145
|
-
require(
|
|
146
|
-
owner() == msg.sender || (s.tokenBound == address(0) && msg.sender == _token),
|
|
147
|
-
ErrorsLib.OnlyOwnerOrTokenCanCall()
|
|
148
|
-
);
|
|
149
|
-
_bindToken(_token);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* @dev See {IERC3643Compliance-unbindToken}.
|
|
154
|
-
*/
|
|
155
|
-
function unbindToken(address _token) external override {
|
|
156
|
-
require(owner() == msg.sender || msg.sender == _token, ErrorsLib.OnlyOwnerOrTokenCanCall());
|
|
157
|
-
|
|
158
|
-
Storage storage s = _getStorage();
|
|
159
|
-
require(_token == s.tokenBound, ErrorsLib.TokenNotBound());
|
|
160
|
-
require(_token != address(0), ErrorsLib.ZeroAddress());
|
|
161
|
-
delete s.tokenBound;
|
|
162
|
-
emit ERC3643EventsLib.TokenUnbound(_token);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
139
|
/**
|
|
166
140
|
* @dev See {IModularCompliance-removeModule}.
|
|
141
|
+
* Deletes the module from the routing set, then calls `unbindCompliance` on it directly so the module
|
|
142
|
+
* drops its own binding record. The call is not best effort on purpose: if the module reverts, or a
|
|
143
|
+
* caller supplies only enough gas for the outer call so the subcall runs out under the 63/64 rule, the
|
|
144
|
+
* whole removal reverts and the module stays bound on both sides. A module that reverts on
|
|
145
|
+
* `unbindCompliance` is removed with {forceRemoveModule}.
|
|
146
|
+
* Restricted to the configured AccessManager role (OWNER).
|
|
147
|
+
* Emits a ModuleRemoved event.
|
|
148
|
+
* @param _module address of the module to remove
|
|
167
149
|
*/
|
|
168
|
-
function removeModule(address _module) external
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
Storage storage s = _getStorage();
|
|
172
|
-
require(s.modules.contains(_module), ErrorsLib.ModuleNotBound());
|
|
150
|
+
function removeModule(address _module) external restricted {
|
|
151
|
+
_removeModule(_module);
|
|
173
152
|
IModule(_module).unbindCompliance(address(this));
|
|
174
|
-
s.modules.remove(_module);
|
|
175
153
|
emit EventsLib.ModuleRemoved(_module);
|
|
176
154
|
}
|
|
177
155
|
|
|
178
156
|
/**
|
|
179
|
-
* @dev See {
|
|
157
|
+
* @dev See {IModularCompliance-forceRemoveModule}.
|
|
158
|
+
* Deletes the module from the routing set without any call into it, so a module that reverts on
|
|
159
|
+
* `unbindCompliance` or everywhere cannot hold the token hostage. The module keeps its own binding
|
|
160
|
+
* record, so the same address cannot be added to this compliance again; a fresh deployment can.
|
|
161
|
+
* Restricted to the configured AccessManager role (OWNER).
|
|
162
|
+
* Emits a ModuleForceRemoved event and no ModuleRemoved, so indexers can tell a forced removal
|
|
163
|
+
* from a regular one.
|
|
164
|
+
* @param _module address of the module to remove
|
|
180
165
|
*/
|
|
181
|
-
function
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
Storage storage s = _getStorage();
|
|
185
|
-
uint256 length = s.modules.length();
|
|
186
|
-
for (uint256 i = 0; i < length; i++) {
|
|
187
|
-
IModule(s.modules.at(i)).moduleTransferAction(_from, _to, _value);
|
|
188
|
-
}
|
|
166
|
+
function forceRemoveModule(address _module) external restricted {
|
|
167
|
+
_removeModule(_module);
|
|
168
|
+
emit EventsLib.ModuleForceRemoved(_module);
|
|
189
169
|
}
|
|
190
170
|
|
|
191
171
|
/**
|
|
192
|
-
* @dev See {
|
|
172
|
+
* @dev See {IModularCompliance-resyncModuleTypes}.
|
|
173
|
+
* Re-reads what the module says it is and files it again, as a rebind would, without touching the
|
|
174
|
+
* module's own state.
|
|
193
175
|
*/
|
|
194
|
-
function
|
|
195
|
-
|
|
196
|
-
require(_value > 0, ErrorsLib.ZeroValue());
|
|
197
|
-
Storage storage s = _getStorage();
|
|
198
|
-
uint256 length = s.modules.length();
|
|
199
|
-
for (uint256 i = 0; i < length; i++) {
|
|
200
|
-
IModule(s.modules.at(i)).moduleMintAction(_to, _value);
|
|
201
|
-
}
|
|
176
|
+
function resyncModuleTypes(address _module) external restricted {
|
|
177
|
+
ModuleSetLib.resyncModuleTypes(_module);
|
|
202
178
|
}
|
|
203
179
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}
|
|
180
|
+
/// @inheritdoc ISettlementHandler
|
|
181
|
+
function handleSettlement(bytes32 originChainKey, MessageTypesLib.SettlementNotification calldata notification)
|
|
182
|
+
external
|
|
183
|
+
onlyBoundToken
|
|
184
|
+
returns (bool haltToken)
|
|
185
|
+
{
|
|
186
|
+
emit EventsLib.SettlementNotified(
|
|
187
|
+
originChainKey, notification.validationId, notification.from, notification.to, notification.amount
|
|
188
|
+
);
|
|
189
|
+
return _handleSettlement(originChainKey, notification);
|
|
215
190
|
}
|
|
216
191
|
|
|
217
192
|
/**
|
|
218
193
|
* @dev See {IModularCompliance-addAndSetModule}.
|
|
219
194
|
*/
|
|
220
|
-
function addAndSetModule(address _module, bytes[] calldata _interactions) external
|
|
195
|
+
function addAndSetModule(address _module, bytes[] calldata _interactions) external restricted {
|
|
221
196
|
require(_interactions.length <= 5, ErrorsLib.ArraySizeLimited(5));
|
|
222
197
|
_addModule(_module);
|
|
223
198
|
for (uint256 i = 0; i < _interactions.length; i++) {
|
|
@@ -228,154 +203,338 @@ contract ModularCompliance is IModularCompliance, Ownable2StepUpgradeable, IERC1
|
|
|
228
203
|
/**
|
|
229
204
|
* @dev See {IModularCompliance-isModuleBound}.
|
|
230
205
|
*/
|
|
231
|
-
function isModuleBound(address _module) external view
|
|
232
|
-
return
|
|
206
|
+
function isModuleBound(address _module) external view returns (bool) {
|
|
207
|
+
return _moduleSet().modules.contains(_module);
|
|
233
208
|
}
|
|
234
209
|
|
|
235
210
|
/**
|
|
236
211
|
* @dev See {IModularCompliance-getModules}.
|
|
237
212
|
*/
|
|
238
|
-
function getModules() external view
|
|
239
|
-
return
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* @dev See {IERC3643Compliance-getTokenBound}.
|
|
244
|
-
*/
|
|
245
|
-
function getTokenBound() external view override returns (address) {
|
|
246
|
-
return _getStorage().tokenBound;
|
|
213
|
+
function getModules() external view returns (address[] memory) {
|
|
214
|
+
return _moduleSet().modules.values();
|
|
247
215
|
}
|
|
248
216
|
|
|
249
217
|
/**
|
|
250
|
-
* @dev See {
|
|
218
|
+
* @dev See {IModularCompliance-getModulesByType}.
|
|
251
219
|
*/
|
|
252
|
-
function
|
|
253
|
-
return
|
|
220
|
+
function getModulesByType(IModule.ModuleType moduleType) external view returns (address[] memory) {
|
|
221
|
+
return _moduleSet().byType[moduleType].values();
|
|
254
222
|
}
|
|
255
223
|
|
|
256
224
|
/**
|
|
257
|
-
* @dev See {
|
|
225
|
+
* @dev See {IModularCompliance-canSpenderCall}.
|
|
226
|
+
* Every `SPENDER` module must agree. The context is built, and the wallets resolved, only when one is
|
|
227
|
+
* bound, so a token with no spender policy pays nothing here.
|
|
258
228
|
*/
|
|
259
|
-
function
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
return true;
|
|
229
|
+
function canSpenderCall(address _spender, address _from, address _to, uint256 _value)
|
|
230
|
+
external
|
|
231
|
+
onlyBoundToken
|
|
232
|
+
returns (bool)
|
|
233
|
+
{
|
|
234
|
+
_transferFromSpender = _spender;
|
|
235
|
+
if (_moduleSet().byType[IModule.ModuleType.SPENDER].length() == 0) return true;
|
|
236
|
+
return _spenderAllowed(_buildNativeContext(_from, _to, _value));
|
|
269
237
|
}
|
|
270
238
|
|
|
271
239
|
/**
|
|
272
240
|
* @dev See {IModularCompliance-addModule}.
|
|
273
241
|
*/
|
|
274
|
-
function addModule(address _module) public
|
|
242
|
+
function addModule(address _module) public restricted {
|
|
275
243
|
_addModule(_module);
|
|
276
244
|
}
|
|
277
245
|
|
|
278
246
|
/**
|
|
279
247
|
* @dev see {IModularCompliance-callModuleFunction}.
|
|
280
248
|
*/
|
|
281
|
-
function callModuleFunction(bytes calldata callData, address _module) public
|
|
249
|
+
function callModuleFunction(bytes calldata callData, address _module) public restricted {
|
|
282
250
|
_callModuleFunction(callData, _module);
|
|
283
251
|
}
|
|
284
252
|
|
|
253
|
+
/* ----- Validation settings ----- */
|
|
254
|
+
|
|
255
|
+
/// @inheritdoc ITransferValidation
|
|
256
|
+
function setDefaultValidityWindow(uint64 duration) external restricted {
|
|
257
|
+
_setDefaultValidityWindow(duration);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/// @inheritdoc ITransferValidation
|
|
261
|
+
function setReconciliationWindow(bytes32 chainKey, uint64 duration) external restricted {
|
|
262
|
+
_setReconciliationWindow(chainKey, duration);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/// @inheritdoc ITransferValidation
|
|
266
|
+
function setIssuancePaused(bytes32 chainKey, bool paused) external restricted {
|
|
267
|
+
_setIssuancePaused(chainKey, paused);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/// @inheritdoc ITransferValidation
|
|
271
|
+
function resolveStuckValidation(uint256 validationId) external restricted {
|
|
272
|
+
_resolveStuckValidation(validationId);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/// @inheritdoc ITransferValidation
|
|
276
|
+
/// @dev Not `restricted`: who may call depends on the clock. The keeper is recognised through the role the
|
|
277
|
+
/// AccessManager binds to this selector, and anyone else is admitted once the second window has passed.
|
|
278
|
+
function discardExpiredValidations(uint256[] calldata validationIds) external {
|
|
279
|
+
_discardExpiredValidations(validationIds);
|
|
280
|
+
}
|
|
281
|
+
|
|
285
282
|
/**
|
|
286
283
|
* @dev See {IERC165-supportsInterface}.
|
|
287
284
|
*/
|
|
288
|
-
function supportsInterface(bytes4 interfaceId) public
|
|
285
|
+
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
|
|
289
286
|
return interfaceId == type(IModularCompliance).interfaceId
|
|
290
|
-
|| interfaceId == type(IERC3643Compliance).interfaceId
|
|
291
|
-
|| interfaceId == type(
|
|
287
|
+
|| interfaceId == type(IERC3643Compliance).interfaceId
|
|
288
|
+
|| interfaceId == type(ISettlementHandler).interfaceId
|
|
289
|
+
|| interfaceId == type(ITransferValidation).interfaceId
|
|
290
|
+
|| interfaceId == type(IComplianceLedger).interfaceId || super.supportsInterface(interfaceId);
|
|
292
291
|
}
|
|
293
292
|
|
|
294
|
-
/// @dev
|
|
295
|
-
///
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
293
|
+
/// @dev Binding policy: an unbound compliance accepts a bind from the token itself (so a Token can
|
|
294
|
+
/// claim a fresh compliance during setup), and anyone else needs the role the AccessManager binds to
|
|
295
|
+
/// `bindToken`, checked the way `restricted` checks it, so an owner granted with a delay schedules the call.
|
|
296
|
+
///
|
|
297
|
+
/// A token claiming the compliance must be one this compliance's AccessManager governs: it has given the
|
|
298
|
+
/// token's `setCompliance` a role. The caller writes its own `compliance()` and `authority()`, so neither
|
|
299
|
+
/// proves anything; only the manager's admin can configure a target, so any contract with no supply could
|
|
300
|
+
/// otherwise bind itself and write positions for any identity through a registry it chose.
|
|
301
|
+
///
|
|
302
|
+
/// The ledger keeps every position from the token's first mint and nothing seeds it, so the new token must
|
|
303
|
+
/// have no supply, and the token it replaces must be able to leave.
|
|
304
|
+
function _authorizeTokenBinding(address token) internal override {
|
|
305
|
+
bool tokenClaimsUnboundCompliance = _getTokenBound() == address(0) && msg.sender == token;
|
|
306
|
+
// A target the manager never configured answers the admin role, 0, for every selector.
|
|
307
|
+
bool tokenGovernedByThisManager =
|
|
308
|
+
IAccessManager(authority()).getTargetFunctionRole(token, IERC3643.setCompliance.selector) != 0;
|
|
309
|
+
bool governedTokenClaimsUnboundCompliance = tokenClaimsUnboundCompliance && tokenGovernedByThisManager;
|
|
310
|
+
if (!governedTokenClaimsUnboundCompliance) _checkCanCall(msg.sender, _msgData());
|
|
311
|
+
require(!_hasSupply(token), ErrorsLib.TokenCirculating());
|
|
312
|
+
_requireBoundTokenCanLeave();
|
|
300
313
|
}
|
|
301
314
|
|
|
302
|
-
/// @dev
|
|
303
|
-
///
|
|
304
|
-
function
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
315
|
+
/// @dev Unbinding does not allow the "first bind" path: only the token itself, or the role bound to
|
|
316
|
+
/// `unbindToken`, and only once the token can leave.
|
|
317
|
+
function _authorizeTokenUnbinding(address token) internal override {
|
|
318
|
+
if (msg.sender != token) _checkCanCall(msg.sender, _msgData());
|
|
319
|
+
_requireBoundTokenCanLeave();
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/// @dev The ledger's positions belong to the bound token's holders, and no path binds a circulating token
|
|
323
|
+
/// back, so the token may leave only once it has no supply. An open validation keeps it too: closing one
|
|
324
|
+
/// releases its reservation on the bound token. A compliance that must change under it is upgraded instead.
|
|
325
|
+
function _requireBoundTokenCanLeave() private view {
|
|
326
|
+
require(!_hasSupply(_getTokenBound()), ErrorsLib.TokenCirculating());
|
|
327
|
+
require(_ledger().pendingTotal == 0, ErrorsLib.ValidationsPending());
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/* ----- The ERC-3643 hooks over the ledger ----- */
|
|
331
|
+
|
|
332
|
+
/// @dev Rule evaluation: the amount must be at most the smallest amount any `RULE` module allows.
|
|
333
|
+
/// Nothing is resolved when no rule is bound.
|
|
334
|
+
///
|
|
335
|
+
/// A sender that resolves to no identity is refused outright while a rule is bound: it would read as a mint
|
|
336
|
+
/// and escape every rule about leaving. A holding wallet resolves to nobody only after the owner swaps the
|
|
337
|
+
/// registry's storage or unbinds a registry from it. The recipient needs no such guard, since the token asks
|
|
338
|
+
/// `isVerified` first, and that requires an active identity even with the eligibility checks disabled.
|
|
339
|
+
function _canTransfer(address from, address to, uint256 value) internal view override returns (bool) {
|
|
340
|
+
if (_moduleSet().byType[IModule.ModuleType.RULE].length() == 0) return true;
|
|
341
|
+
IModule.TransferContext memory ctx = _buildNativeContext(from, to, value);
|
|
342
|
+
if (from != address(0) && ctx.fromIdentity == address(0)) return false;
|
|
343
|
+
return value <= _minAllowedAmount(ctx);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/// @dev A transfer: the position follows the tokens, then every `TRACKER` module is told.
|
|
347
|
+
function _transferred(address from, address to, uint256 value) internal override {
|
|
348
|
+
_applyMovement(from, to, value, MovementKindLib.TRANSFER);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/// @dev A mint: no sender, the recipient's position grows.
|
|
352
|
+
function _created(address to, uint256 value) internal override {
|
|
353
|
+
_applyMovement(address(0), to, value, MovementKindLib.MINT);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/// @dev A burn: no recipient, the sender's position shrinks.
|
|
357
|
+
function _destroyed(address from, uint256 value) internal override {
|
|
358
|
+
_applyMovement(from, address(0), value, MovementKindLib.BURN);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/// @dev See {IModularCompliance-syncOwner}. The owner change only, at adjustment zero: no movement is counted
|
|
362
|
+
/// and no module is told.
|
|
363
|
+
function syncOwner(address wallet) external onlyBoundToken {
|
|
364
|
+
_currentOwner(wallet, address(_boundRegistry().identity(wallet)), 0);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/// @dev See {IModularCompliance-agentTransferred}. Same guards as `transferred`, which this replaces on
|
|
368
|
+
/// the token's forced, recovery and delegation paths so that the trackers learn what moved the tokens.
|
|
369
|
+
function agentTransferred(address from, address to, uint256 amount, uint8 kind) external onlyBoundToken {
|
|
370
|
+
require(from != address(0) && to != address(0), ErrorsLib.ZeroAddress());
|
|
371
|
+
_applyMovement(from, to, amount, kind);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/// @dev Moves the positions and tells the trackers. One function serves all three hooks: the absent side of
|
|
375
|
+
/// a mint or a burn is a zero wallet and stays a zero identity. The context carries the kind the token
|
|
376
|
+
/// reported and the spender the rules were asked about, with each side's owner settled.
|
|
377
|
+
///
|
|
378
|
+
/// The hooks run after the token moved the balances, so each side's owner is settled with that already
|
|
379
|
+
/// applied: the sender's balance is what it holds now plus what just left, the recipient's what it holds now
|
|
380
|
+
/// minus what just arrived. A wallet whose owner changed since it was last credited has its balance moved
|
|
381
|
+
/// to the new owner here, before the movement itself is counted.
|
|
382
|
+
///
|
|
383
|
+
/// A self-transfer leaves the wallet's balance where it was, so neither side adds the value back: the
|
|
384
|
+
/// adjustment is the net effect on the wallet, zero when sender and recipient are the same. A delegation
|
|
385
|
+
/// also names the holder on both sides, but the token burned the amount before reporting it, so it keeps
|
|
386
|
+
/// the full adjustment.
|
|
387
|
+
///
|
|
388
|
+
/// The spender of a `transferFrom` is forgotten before the trackers run, so a transfer one of them makes
|
|
389
|
+
/// is not taken for it.
|
|
390
|
+
function _applyMovement(address from, address to, uint256 value, uint8 kind) private {
|
|
391
|
+
ITREXRegistry registry = _boundRegistry();
|
|
392
|
+
address fromIdentity;
|
|
393
|
+
address toIdentity;
|
|
394
|
+
// A self-transfer leaves the balance where it was; a delegation reports holder to holder after its burn.
|
|
395
|
+
bool balanceUnchanged = from == to && kind != MovementKindLib.DELEGATION;
|
|
396
|
+
int256 adjustment = balanceUnchanged ? int256(0) : int256(value);
|
|
397
|
+
if (from != address(0)) fromIdentity = _currentOwner(from, address(registry.identity(from)), adjustment);
|
|
398
|
+
if (to != address(0)) toIdentity = _currentOwner(to, address(registry.identity(to)), -adjustment);
|
|
399
|
+
|
|
400
|
+
IModule.TransferContext memory ctx = TransferContextLib.native(
|
|
401
|
+
address(this), kind, fromIdentity, toIdentity, from, to, value, _transferFromSpenderEnvelope()
|
|
402
|
+
);
|
|
403
|
+
_transferFromSpender = address(0);
|
|
404
|
+
_movePosition(ctx.fromIdentity, ctx.toIdentity, ctx.fromWallet, ctx.toWallet, ctx.amountMax);
|
|
405
|
+
_callAfterTransfer(ctx);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/// @dev Resolves both wallets once, through the registry's native lookup, and builds the context of a
|
|
409
|
+
/// native movement. A zero wallet (the mint or burn side) stays a zero identity and a zero key. The
|
|
410
|
+
/// spender is the caller of the `transferFrom` in progress, empty on any other movement.
|
|
411
|
+
function _buildNativeContext(address from, address to, uint256 value)
|
|
412
|
+
private
|
|
413
|
+
view
|
|
414
|
+
returns (IModule.TransferContext memory)
|
|
415
|
+
{
|
|
416
|
+
ITREXRegistry registry = _boundRegistry();
|
|
417
|
+
address fromIdentity;
|
|
418
|
+
address toIdentity;
|
|
419
|
+
if (from != address(0)) fromIdentity = address(registry.identity(from));
|
|
420
|
+
if (to != address(0)) toIdentity = address(registry.identity(to));
|
|
421
|
+
// Only a transfer or a mint is previewed: a burn asks no rule, and an agent's movement asks none either.
|
|
422
|
+
uint8 kind = from == address(0) ? MovementKindLib.MINT : MovementKindLib.TRANSFER;
|
|
423
|
+
return TransferContextLib.native(
|
|
424
|
+
address(this), kind, fromIdentity, toIdentity, from, to, value, _transferFromSpenderEnvelope()
|
|
313
425
|
);
|
|
426
|
+
}
|
|
314
427
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
428
|
+
/// @dev {_transferFromSpender} as the ERC-7930 envelope a module reads, empty when no `transferFrom` runs.
|
|
429
|
+
function _transferFromSpenderEnvelope() private view returns (bytes memory) {
|
|
430
|
+
if (_transferFromSpender == address(0)) return "";
|
|
431
|
+
return InteroperableAddress.formatEvmV1(block.chainid, _transferFromSpender);
|
|
318
432
|
}
|
|
319
433
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
///
|
|
323
|
-
function
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
) {
|
|
349
|
-
returndatacopy(0, 0, returndatasize()) // Copy return data to memory starting at position 0
|
|
350
|
-
revert(0, returndatasize()) // Revert the transaction with the return data
|
|
351
|
-
}
|
|
434
|
+
/* ----- What the validation layer needs ----- */
|
|
435
|
+
|
|
436
|
+
/// @inheritdoc TransferValidation
|
|
437
|
+
function _boundToken() internal view override returns (IToken) {
|
|
438
|
+
return IToken(_getTokenBound());
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/// @inheritdoc TransferValidation
|
|
442
|
+
function _boundRegistry() internal view override returns (ITREXRegistry) {
|
|
443
|
+
return ITREXRegistry(address(_boundToken().identityRegistry()));
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/// @inheritdoc TransferValidation
|
|
447
|
+
function _canCallSelector(address caller, bytes4 selector) internal view override returns (bool) {
|
|
448
|
+
(bool immediate,) = AuthorityUtils.canCallWithDelay(authority(), caller, address(this), selector);
|
|
449
|
+
return immediate;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/// @inheritdoc TransferValidation
|
|
453
|
+
/// @dev The smallest answer of the `RULE` modules. `allowedAmount` is a view on the interface, so each
|
|
454
|
+
/// call is a `staticcall` and a module that writes there reverts.
|
|
455
|
+
function _minAllowedAmount(IModule.TransferContext memory ctx) internal view override returns (uint256 allowed) {
|
|
456
|
+
allowed = type(uint256).max;
|
|
457
|
+
EnumerableSet.AddressSet storage rules = _moduleSet().byType[IModule.ModuleType.RULE];
|
|
458
|
+
uint256 length = rules.length();
|
|
459
|
+
for (uint256 i = 0; i < length; i++) {
|
|
460
|
+
uint256 answer = IModule(rules.at(i)).allowedAmount(ctx);
|
|
461
|
+
if (answer < allowed) allowed = answer;
|
|
352
462
|
}
|
|
463
|
+
}
|
|
353
464
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
function _selector(bytes calldata callData) internal pure returns (bytes4 result) {
|
|
361
|
-
if (callData.length >= 4) {
|
|
362
|
-
// NOTE: Read the first word of the interaction's calldata. The
|
|
363
|
-
// value does not need to be shifted since `bytesN` values are left
|
|
364
|
-
// aligned, and the value does not need to be masked since masking
|
|
365
|
-
// occurs when the value is accessed and not stored:
|
|
366
|
-
// <https://docs.soliditylang.org/en/v0.7.6/abi-spec.html#encoding-of-indexed-event-parameters>
|
|
367
|
-
// <https://docs.soliditylang.org/en/v0.7.6/assembly.html#access-to-external-variables-functions-and-libraries>
|
|
368
|
-
assembly {
|
|
369
|
-
result := calldataload(callData.offset)
|
|
370
|
-
}
|
|
465
|
+
/// @inheritdoc TransferValidation
|
|
466
|
+
function _spenderAllowed(IModule.TransferContext memory ctx) internal view override returns (bool) {
|
|
467
|
+
EnumerableSet.AddressSet storage spenderRules = _moduleSet().byType[IModule.ModuleType.SPENDER];
|
|
468
|
+
uint256 length = spenderRules.length();
|
|
469
|
+
for (uint256 i = 0; i < length; i++) {
|
|
470
|
+
if (!IModule(spenderRules.at(i)).moduleCheckSpender(ctx)) return false;
|
|
371
471
|
}
|
|
472
|
+
return true;
|
|
372
473
|
}
|
|
373
474
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
475
|
+
/// @inheritdoc TransferValidation
|
|
476
|
+
function _callAfterTransfer(IModule.TransferContext memory ctx) internal override {
|
|
477
|
+
EnumerableSet.AddressSet storage trackers = _moduleSet().byType[IModule.ModuleType.TRACKER];
|
|
478
|
+
uint256 length = trackers.length();
|
|
479
|
+
for (uint256 i = 0; i < length; i++) {
|
|
480
|
+
IModule(trackers.at(i)).afterTransfer(ctx);
|
|
377
481
|
}
|
|
378
482
|
}
|
|
379
483
|
|
|
380
|
-
|
|
484
|
+
/// @inheritdoc TransferValidation
|
|
485
|
+
/// @dev The token is the wire's only author: it pins the route per leg and refuses a closed chain.
|
|
486
|
+
function _dispatchLeg(bytes32 chainKey, uint256 validationId, bytes memory body) internal override {
|
|
487
|
+
IToken(_getTokenBound()).dispatchComplianceValidation(chainKey, validationId, body);
|
|
488
|
+
}
|
|
381
489
|
|
|
490
|
+
/// @inheritdoc TransferValidation
|
|
491
|
+
function _settleOnToken(bytes memory from, bytes memory to, uint256 amount, uint256 validationId)
|
|
492
|
+
internal
|
|
493
|
+
override
|
|
494
|
+
{
|
|
495
|
+
_boundToken().settleValidation(from, to, amount, validationId);
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/// @inheritdoc TransferValidation
|
|
499
|
+
function _holdOnToken(bytes memory from, uint256 amount, uint256 validationId, uint256 reserved) internal override {
|
|
500
|
+
_boundToken().holdInTransit(from, amount, validationId, reserved);
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
/// @inheritdoc TransferValidation
|
|
504
|
+
function _releaseOnToken(bytes memory wallet, uint256 amount) internal override {
|
|
505
|
+
_boundToken().releaseFromValidation(wallet, amount);
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
/// @inheritdoc TransferValidation
|
|
509
|
+
function _returnHeldOnToken(bytes memory to, uint256 validationId) internal override {
|
|
510
|
+
_boundToken().returnHeldInTransit(to, validationId);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/* ----- Module lifecycle ----- */
|
|
514
|
+
|
|
515
|
+
/// @dev Binds a module. No caller check: wrappers enforce it. See {ModuleSetLib-addModule}.
|
|
516
|
+
function _addModule(address _module) internal {
|
|
517
|
+
ModuleSetLib.addModule(_module);
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
/// @dev Takes a module out of every list it sits in, without calling into it.
|
|
521
|
+
function _removeModule(address _module) internal {
|
|
522
|
+
ModuleSetLib.removeModule(_module);
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
/// @dev Forwards `callData` to a bound `_module`. No caller check: wrappers enforce it.
|
|
526
|
+
function _callModuleFunction(bytes calldata callData, address _module) internal {
|
|
527
|
+
ModuleSetLib.callModuleFunction(callData, _module);
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
/// @dev An address with no code has no supply. A compliance is bound to the token's predicted address before
|
|
531
|
+
/// the token is deployed, and a spare compliance is prepared by binding a placeholder then unbinding it.
|
|
532
|
+
function _hasSupply(address token) private view returns (bool) {
|
|
533
|
+
return token.code.length != 0 && IToken(token).totalSupply() != 0;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
function _moduleSet() private pure returns (ModuleSetLib.ModuleSet storage) {
|
|
537
|
+
return ModuleSetLib.layout();
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
}
|