@t-rex-network/t-rex 4.2.0-beta1 → 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 +24 -27
- 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 +14 -11
- 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,339 @@
|
|
|
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) 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/>.
|
|
59
|
+
|
|
60
|
+
pragma solidity 0.8.30;
|
|
61
|
+
|
|
62
|
+
import { IERC3643 } from "../ERC-3643/IERC3643.sol";
|
|
63
|
+
import { IModularCompliance } from "../compliance/modular/IModularCompliance.sol";
|
|
64
|
+
import { MovementKindLib } from "../compliance/modular/MovementKindLib.sol";
|
|
65
|
+
import { TREXMessagingLib } from "../interop/TREXMessagingLib.sol";
|
|
66
|
+
import { ErrorsLib } from "../libraries/ErrorsLib.sol";
|
|
67
|
+
import { EventsLib } from "../libraries/EventsLib.sol";
|
|
68
|
+
import { MessageTypesLib } from "../libraries/MessageTypesLib.sol";
|
|
69
|
+
import { WalletKeyLib } from "../libraries/WalletKeyLib.sol";
|
|
70
|
+
import { ITREXRegistry } from "../registry/interface/ITREXRegistry.sol";
|
|
71
|
+
import { TokenLedgerLib } from "./TokenLedgerLib.sol";
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @title TokenDelegationLib
|
|
75
|
+
* @dev The checks, the bookkeeping and the messages of the two movements that change a position's location and
|
|
76
|
+
* never its owner: a delegation-out, native wallet to satellite wallet of one identity, and a recall, the way
|
|
77
|
+
* back. Deployed once and linked.
|
|
78
|
+
*
|
|
79
|
+
* The token reaches this by DELEGATECALL, so the storage is its own `erc3643.storage.TREXToken` namespace, the
|
|
80
|
+
* registry, the compliance and the gateway see the token as their caller, and every event is the token's. The
|
|
81
|
+
* registry and the compliance are read from the token's own getters, so the token passes neither. The native
|
|
82
|
+
* half of each movement stays in the token, since it is the ERC-20 balance this library cannot reach: the token
|
|
83
|
+
* burns before {delegateOut} and mints after {consumeBurnProof}; everything bridged happens here.
|
|
84
|
+
*
|
|
85
|
+
* Both instructions are retryable, never written off: {resend} sends an instruction again byte for byte, under
|
|
86
|
+
* the same id, to the same peer, and the Lite acts on each id once. Nothing here checks a caller or the pause:
|
|
87
|
+
* the token's entry points do, before they reach this.
|
|
88
|
+
*/
|
|
89
|
+
library TokenDelegationLib {
|
|
90
|
+
|
|
91
|
+
/// @dev `resend` kind of a delegation's mint instruction.
|
|
92
|
+
uint8 internal constant DELEGATION = 0;
|
|
93
|
+
|
|
94
|
+
/// @dev `resend` kind of a recall instruction.
|
|
95
|
+
uint8 internal constant RECALL = 1;
|
|
96
|
+
|
|
97
|
+
/// @dev The rest of a delegation-out, once the token has burned `amount` of `holder`'s native balance: the burn
|
|
98
|
+
/// stayed inside the free balance, the bridged position of `toWallet` is credited under a fresh delegation id
|
|
99
|
+
/// (`DelegatedOut`), both wallets sit on one identity, the registry admits the recipient, the compliance is told,
|
|
100
|
+
/// the instruction is committed and sent. Any refusal reverts the burn with it, so nothing is delegated that the
|
|
101
|
+
/// satellite is not told to mint.
|
|
102
|
+
/// @return sendId The gateway's id for the instruction.
|
|
103
|
+
function delegateOut(address holder, bytes calldata toWallet, uint256 amount) external returns (bytes32 sendId) {
|
|
104
|
+
uint256 delegationId = _creditDelegation(holder, toWallet, amount);
|
|
105
|
+
|
|
106
|
+
_requireLinked(holder, toWallet);
|
|
107
|
+
require(_registry().isWalletVerified(toWallet), ErrorsLib.UnverifiedWallet(toWallet));
|
|
108
|
+
|
|
109
|
+
_compliance().agentTransferred(holder, holder, amount, MovementKindLib.DELEGATION);
|
|
110
|
+
|
|
111
|
+
bytes32 chainKey = _chainKeyOf(toWallet);
|
|
112
|
+
TokenLedgerLib.layout().delegations[delegationId] =
|
|
113
|
+
_commitment(chainKey, keccak256(TREXMessagingLib.peerFor(chainKey)), toWallet, amount, holder);
|
|
114
|
+
|
|
115
|
+
return _sendMint(chainKey, delegationId, toWallet, amount, holder);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/// @dev The bridged half of a delegation-out, through the ledger's own transition: the token already burned, so
|
|
119
|
+
/// the free balance before the burn is what it holds now plus `amount`, less what is frozen. Then the delegation
|
|
120
|
+
/// takes the next id.
|
|
121
|
+
function _creditDelegation(address holder, bytes calldata toWallet, uint256 amount)
|
|
122
|
+
private
|
|
123
|
+
returns (uint256 delegationId)
|
|
124
|
+
{
|
|
125
|
+
require(amount != 0, ErrorsLib.ZeroValue());
|
|
126
|
+
IERC3643 token = IERC3643(address(this));
|
|
127
|
+
uint256 freeBefore = token.balanceOf(holder) + amount - token.getFrozenTokens(holder);
|
|
128
|
+
bytes32 toKey = TokenLedgerLib.creditFromNative(holder, toWallet, amount, freeBefore);
|
|
129
|
+
delegationId = ++TokenLedgerLib.layout().lastDelegationId;
|
|
130
|
+
|
|
131
|
+
emit EventsLib.DelegatedOut(holder, toKey, delegationId, toWallet, amount);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/// @dev Records a recall instruction and sends it. One recall at a time per wallet. The amount is bounded by the
|
|
135
|
+
/// wallet's bridged position so the proof that answers can always apply, and not by its reservations: a
|
|
136
|
+
/// validation that executes on the satellite first leaves the satellite less to burn, and the proof carries
|
|
137
|
+
/// what it burned, down to zero. The gateway and the peer it goes to are recorded, and only they may answer.
|
|
138
|
+
/// @return recallId The id the proof must answer with.
|
|
139
|
+
function instructRecall(bytes calldata wallet, uint256 amount, address nativeWallet)
|
|
140
|
+
external
|
|
141
|
+
returns (uint256 recallId)
|
|
142
|
+
{
|
|
143
|
+
require(amount != 0, ErrorsLib.ZeroValue());
|
|
144
|
+
require(nativeWallet != address(0), ErrorsLib.ZeroAddress());
|
|
145
|
+
_requireLinked(nativeWallet, wallet);
|
|
146
|
+
|
|
147
|
+
bytes32 walletKey = WalletKeyLib.satelliteKey(wallet);
|
|
148
|
+
TokenLedgerLib.TokenStorage storage s = TokenLedgerLib.layout();
|
|
149
|
+
require(s.openRecall[walletKey] == 0, ErrorsLib.RecallPending(walletKey, s.openRecall[walletKey]));
|
|
150
|
+
uint256 balance = s.bridgedBalance[walletKey];
|
|
151
|
+
require(amount <= balance, ErrorsLib.InsufficientBridgedBalance(wallet, balance, amount));
|
|
152
|
+
|
|
153
|
+
bytes32 chainKey = _chainKeyOf(wallet);
|
|
154
|
+
recallId = ++s.lastRecallId;
|
|
155
|
+
s.recalls[recallId] = TokenLedgerLib.PendingRecall({
|
|
156
|
+
walletKey: walletKey,
|
|
157
|
+
chainKey: chainKey,
|
|
158
|
+
nativeWallet: nativeWallet,
|
|
159
|
+
amount: amount,
|
|
160
|
+
gateway: TREXMessagingLib.layout().routes[chainKey],
|
|
161
|
+
peerKey: keccak256(TREXMessagingLib.peerFor(chainKey))
|
|
162
|
+
});
|
|
163
|
+
s.openRecall[walletKey] = recallId;
|
|
164
|
+
|
|
165
|
+
emit EventsLib.RecallInstructed(recallId, walletKey, nativeWallet, wallet, amount);
|
|
166
|
+
|
|
167
|
+
_sendRecall(chainKey, recallId, wallet, amount, nativeWallet);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/// @dev Judges an attributed burn proof against the recall it answers, settles that recall, and applies the
|
|
171
|
+
/// bridged half of the credit.
|
|
172
|
+
///
|
|
173
|
+
/// A proof for an open recall must name its wallet and chain and prove at most the instructed amount, or it
|
|
174
|
+
/// reverts and stays deliverable. The identity link is checked again, then the compliance follows any relink
|
|
175
|
+
/// of the native wallet before the credit lands, so the wallet's existing balance is attributed to its current
|
|
176
|
+
/// owner and the credit, already counted in that identity's position as a bridged one, is not migrated with
|
|
177
|
+
/// it. The proof is recorded, the bridged position debited (`Recalled`), and the token mints the native half.
|
|
178
|
+
/// A zero proof settles the same way with nothing to move.
|
|
179
|
+
///
|
|
180
|
+
/// With no open recall: the very proof that settled it, from the same chain, is a duplicate and changes
|
|
181
|
+
/// nothing; anything else, a recall never issued or a different proof for a settled one, is a message the
|
|
182
|
+
/// token cannot account for and reports `halt`, as a replayed settlement does.
|
|
183
|
+
/// @return halt Whether the token must pause itself.
|
|
184
|
+
/// @return nativeWallet The wallet the token mints to, as the instruction recorded it.
|
|
185
|
+
/// @return amount What the token mints: what the satellite proved it burned, zero when nothing is credited.
|
|
186
|
+
function consumeBurnProof(bytes32 originChainKey, bytes memory body)
|
|
187
|
+
external
|
|
188
|
+
returns (bool halt, address nativeWallet, uint256 amount)
|
|
189
|
+
{
|
|
190
|
+
MessageTypesLib.BurnProof memory proof = MessageTypesLib.decodeBurnProof(body);
|
|
191
|
+
bytes32 proofHash = keccak256(abi.encode(originChainKey, body));
|
|
192
|
+
|
|
193
|
+
emit EventsLib.BurnProofReceived(originChainKey, proof.recallId, proof.burnedWallet, proof.amount);
|
|
194
|
+
|
|
195
|
+
TokenLedgerLib.TokenStorage storage s = TokenLedgerLib.layout();
|
|
196
|
+
TokenLedgerLib.PendingRecall storage recall = s.recalls[proof.recallId];
|
|
197
|
+
if (recall.amount == 0) {
|
|
198
|
+
if (s.settledProofs[proof.recallId] == proofHash) {
|
|
199
|
+
emit EventsLib.BurnProofDuplicate(proof.recallId, originChainKey);
|
|
200
|
+
return (false, address(0), 0);
|
|
201
|
+
}
|
|
202
|
+
emit EventsLib.ReplayedBurnProof(proof.recallId, originChainKey);
|
|
203
|
+
return (true, address(0), 0);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
require(
|
|
207
|
+
keccak256(proof.burnedWallet) == recall.walletKey && originChainKey == recall.chainKey,
|
|
208
|
+
ErrorsLib.RecallMismatch(proof.recallId)
|
|
209
|
+
);
|
|
210
|
+
require(
|
|
211
|
+
proof.amount <= recall.amount, ErrorsLib.RecallAmountExceeded(proof.recallId, recall.amount, proof.amount)
|
|
212
|
+
);
|
|
213
|
+
|
|
214
|
+
nativeWallet = recall.nativeWallet;
|
|
215
|
+
amount = proof.amount;
|
|
216
|
+
bytes32 walletKey = recall.walletKey;
|
|
217
|
+
_requireLinked(nativeWallet, proof.burnedWallet);
|
|
218
|
+
_compliance().syncOwner(nativeWallet);
|
|
219
|
+
|
|
220
|
+
delete s.openRecall[walletKey];
|
|
221
|
+
delete s.recalls[proof.recallId];
|
|
222
|
+
s.settledProofs[proof.recallId] = proofHash;
|
|
223
|
+
|
|
224
|
+
emit EventsLib.RecallSettled(proof.recallId, originChainKey, amount);
|
|
225
|
+
|
|
226
|
+
if (amount != 0) {
|
|
227
|
+
TokenLedgerLib.debitToNative(proof.burnedWallet, nativeWallet, amount);
|
|
228
|
+
emit EventsLib.Recalled(walletKey, nativeWallet, proof.burnedWallet, amount);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/// @dev Sends an instruction again, unchanged, through the chain's current route, to the peer it first went to.
|
|
233
|
+
///
|
|
234
|
+
/// A delegation (`kind` 0) is resent from the fields the caller supplies, `abi.encode(toWallet, amount, holder,
|
|
235
|
+
/// peer)`, which must hash to the commitment stored at dispatch. A recall (`kind` 1) is resent from its stored
|
|
236
|
+
/// record and the `abi.encode(wallet)` the caller supplies, which must be the recorded wallet; it is refused
|
|
237
|
+
/// once settled, and its admitted gateway moves to the current route, since the Lite answers through the
|
|
238
|
+
/// gateway that delivered the resend. Either way the chain's peer must still be the one the instruction was
|
|
239
|
+
/// addressed to: a resend never retargets. Nothing moves on this chain.
|
|
240
|
+
/// @return sendId The gateway's id for the resent instruction.
|
|
241
|
+
function resend(uint8 kind, uint256 id, bytes calldata data) external returns (bytes32 sendId) {
|
|
242
|
+
TokenLedgerLib.TokenStorage storage s = TokenLedgerLib.layout();
|
|
243
|
+
bytes32 chainKey;
|
|
244
|
+
if (kind == DELEGATION) {
|
|
245
|
+
(bytes memory toWallet, uint256 amount, address holder, bytes memory peer) =
|
|
246
|
+
abi.decode(data, (bytes, uint256, address, bytes));
|
|
247
|
+
chainKey = _chainKeyOf(toWallet);
|
|
248
|
+
bytes32 committed = s.delegations[id];
|
|
249
|
+
require(
|
|
250
|
+
committed != 0 && committed == _commitment(chainKey, keccak256(peer), toWallet, amount, holder),
|
|
251
|
+
ErrorsLib.DelegationMismatch(id)
|
|
252
|
+
);
|
|
253
|
+
_requireSamePeer(chainKey, keccak256(peer));
|
|
254
|
+
sendId = _sendMint(chainKey, id, toWallet, amount, holder);
|
|
255
|
+
} else if (kind == RECALL) {
|
|
256
|
+
bytes memory wallet = abi.decode(data, (bytes));
|
|
257
|
+
TokenLedgerLib.PendingRecall storage recall = s.recalls[id];
|
|
258
|
+
require(recall.amount != 0, ErrorsLib.RecallNotPending(id));
|
|
259
|
+
require(keccak256(wallet) == recall.walletKey, ErrorsLib.RecallMismatch(id));
|
|
260
|
+
chainKey = recall.chainKey;
|
|
261
|
+
_requireSamePeer(chainKey, recall.peerKey);
|
|
262
|
+
recall.gateway = TREXMessagingLib.layout().routes[chainKey];
|
|
263
|
+
sendId = _sendRecall(chainKey, id, wallet, recall.amount, recall.nativeWallet);
|
|
264
|
+
} else {
|
|
265
|
+
revert ErrorsLib.UnknownResendKind(kind);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
emit EventsLib.InstructionResent(kind, id, chainKey, sendId);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/// @dev Both wallets must resolve to one existing identity. Attribution, not admission: a revoked wallet
|
|
272
|
+
/// still resolves, since a recall is how a revoked position comes home.
|
|
273
|
+
function _requireLinked(address nativeWallet, bytes memory wallet) private view {
|
|
274
|
+
ITREXRegistry registry = _registry();
|
|
275
|
+
address identity = address(registry.identity(nativeWallet));
|
|
276
|
+
require(
|
|
277
|
+
identity != address(0) && identity == address(registry.resolveIdentity(wallet)),
|
|
278
|
+
ErrorsLib.WalletsNotLinked(nativeWallet, wallet)
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/// @dev The token's registry, through its own getter: run by DELEGATECALL, `address(this)` is the token.
|
|
283
|
+
function _registry() private view returns (ITREXRegistry) {
|
|
284
|
+
return ITREXRegistry(address(IERC3643(address(this)).identityRegistry()));
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/// @dev The token's compliance, through its own getter.
|
|
288
|
+
function _compliance() private view returns (IModularCompliance) {
|
|
289
|
+
return IModularCompliance(address(IERC3643(address(this)).compliance()));
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function _requireSamePeer(bytes32 chainKey, bytes32 peerKey) private view {
|
|
293
|
+
require(keccak256(TREXMessagingLib.peerFor(chainKey)) == peerKey, ErrorsLib.PeerChanged(chainKey));
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
function _commitment(bytes32 chainKey, bytes32 peerKey, bytes memory toWallet, uint256 amount, address holder)
|
|
297
|
+
private
|
|
298
|
+
pure
|
|
299
|
+
returns (bytes32)
|
|
300
|
+
{
|
|
301
|
+
return keccak256(abi.encode(chainKey, peerKey, toWallet, amount, holder));
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function _sendMint(bytes32 chainKey, uint256 delegationId, bytes memory toWallet, uint256 amount, address holder)
|
|
305
|
+
private
|
|
306
|
+
returns (bytes32)
|
|
307
|
+
{
|
|
308
|
+
return TREXMessagingLib.sendMessage(
|
|
309
|
+
chainKey,
|
|
310
|
+
MessageTypesLib.Message.MINT_INSTRUCTION,
|
|
311
|
+
abi.encode(
|
|
312
|
+
MessageTypesLib.MintInstruction({
|
|
313
|
+
delegationId: delegationId, toWallet: toWallet, amount: amount, holder: holder
|
|
314
|
+
})
|
|
315
|
+
)
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function _sendRecall(bytes32 chainKey, uint256 recallId, bytes memory wallet, uint256 amount, address nativeWallet)
|
|
320
|
+
private
|
|
321
|
+
returns (bytes32)
|
|
322
|
+
{
|
|
323
|
+
return TREXMessagingLib.sendMessage(
|
|
324
|
+
chainKey,
|
|
325
|
+
MessageTypesLib.Message.RECALL_INSTRUCTION,
|
|
326
|
+
abi.encode(
|
|
327
|
+
MessageTypesLib.RecallInstruction({
|
|
328
|
+
recallId: recallId, wallet: wallet, amount: amount, nativeWallet: nativeWallet
|
|
329
|
+
})
|
|
330
|
+
)
|
|
331
|
+
);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
function _chainKeyOf(bytes memory wallet) private pure returns (bytes32) {
|
|
335
|
+
(bytes2 chainType, bytes memory chainReference,) = WalletKeyLib.parse(wallet);
|
|
336
|
+
return MessageTypesLib.chainKey(chainType, chainReference);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
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) 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/>.
|
|
59
|
+
|
|
60
|
+
pragma solidity 0.8.30;
|
|
61
|
+
|
|
62
|
+
import { ERC165Checker } from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
|
|
63
|
+
|
|
64
|
+
import { IERC3643Compliance } from "../ERC-3643/IERC3643Compliance.sol";
|
|
65
|
+
import { IERC3643IdentityRegistry } from "../ERC-3643/IERC3643IdentityRegistry.sol";
|
|
66
|
+
import { IModularCompliance } from "../compliance/modular/IModularCompliance.sol";
|
|
67
|
+
import { ISettlementHandler } from "../interop/ISettlementHandler.sol";
|
|
68
|
+
import { ErrorsLib } from "../libraries/ErrorsLib.sol";
|
|
69
|
+
import { ITREXRegistry } from "../registry/interface/ITREXRegistry.sol";
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @title TokenGuardsLib
|
|
73
|
+
* @dev The checks behind the token's collaborator setters, deployed once and linked. The token reaches
|
|
74
|
+
* this by DELEGATECALL, so every contract it talks to sees the token as its caller. Unbinding the current
|
|
75
|
+
* compliance happens here; writing the new pointer, the bind and the event stay in the token.
|
|
76
|
+
*/
|
|
77
|
+
library TokenGuardsLib {
|
|
78
|
+
|
|
79
|
+
/// @dev A token with supply keeps its registry, and the new one must advertise the standard interface and
|
|
80
|
+
/// the T-REX one. Reverts `TokenCirculating`, then `InvalidIdentityRegistry`.
|
|
81
|
+
/// @param current the registry the token has now, zero during initialization
|
|
82
|
+
/// @param supply the token's total supply, native and bridged
|
|
83
|
+
function checkIdentityRegistry(address current, address identityRegistryAddress, uint256 supply) external view {
|
|
84
|
+
require(current == address(0) || supply == 0, ErrorsLib.TokenCirculating());
|
|
85
|
+
|
|
86
|
+
// The token's recovery and delegation, and the spender check on every `transferFrom`, call T-REX
|
|
87
|
+
// methods outside the standard interface, which would revert on a registry missing them.
|
|
88
|
+
bytes4[] memory calledInterfaces = new bytes4[](2);
|
|
89
|
+
calledInterfaces[0] = type(IERC3643IdentityRegistry).interfaceId;
|
|
90
|
+
calledInterfaces[1] = type(ITREXRegistry).interfaceId;
|
|
91
|
+
require(
|
|
92
|
+
ERC165Checker.supportsAllInterfaces(identityRegistryAddress, calledInterfaces),
|
|
93
|
+
ErrorsLib.InvalidIdentityRegistry()
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/// @dev A token with supply keeps its compliance; the new one must advertise every interface the token
|
|
98
|
+
/// calls on it and be bound to no token; the current one, if any, is unbound. The token then writes the
|
|
99
|
+
/// pointer and binds. Reverts `TokenCirculating`, then `InvalidCompliance`, then
|
|
100
|
+
/// `ComplianceAlreadyBoundToToken`.
|
|
101
|
+
/// @param current the compliance the token has now, zero during initialization
|
|
102
|
+
/// @param supply the token's total supply, native and bridged
|
|
103
|
+
function prepareCompliance(address current, address complianceAddress, uint256 supply) external {
|
|
104
|
+
require(current == address(0) || supply == 0, ErrorsLib.TokenCirculating());
|
|
105
|
+
|
|
106
|
+
// Checked before getTokenBound() so a wrong contract gives a named error. A compliance missing one of
|
|
107
|
+
// these is accepted, then every `transferFrom` (`canSpenderCall`), agent movement or settlement
|
|
108
|
+
// delivery reverts, and once tokens are minted the compliance can no longer be replaced.
|
|
109
|
+
bytes4[] memory calledInterfaces = new bytes4[](3);
|
|
110
|
+
calledInterfaces[0] = type(IERC3643Compliance).interfaceId;
|
|
111
|
+
calledInterfaces[1] = type(IModularCompliance).interfaceId;
|
|
112
|
+
calledInterfaces[2] = type(ISettlementHandler).interfaceId;
|
|
113
|
+
require(ERC165Checker.supportsAllInterfaces(complianceAddress, calledInterfaces), ErrorsLib.InvalidCompliance());
|
|
114
|
+
|
|
115
|
+
address boundToken = IModularCompliance(complianceAddress).getTokenBound();
|
|
116
|
+
require(boundToken == address(0), ErrorsLib.ComplianceAlreadyBoundToToken());
|
|
117
|
+
|
|
118
|
+
if (current != address(0)) {
|
|
119
|
+
IERC3643Compliance(current).unbindToken(address(this));
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
}
|