@t-rex-network/t-rex 5.0.0-beta2 → 5.0.0-beta3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE.md +78 -0
- package/README.md +19 -22
- package/contracts/{roles/AgentRole.sol → ERC-3643/ERC3643ErrorsLib.sol} +60 -33
- package/contracts/ERC-3643/IERC3643.sol +61 -5
- package/contracts/ERC-3643/IERC3643ClaimTopicsRegistry.sol +11 -2
- package/contracts/ERC-3643/IERC3643Compliance.sol +21 -8
- package/contracts/ERC-3643/IERC3643IdentityRegistry.sol +33 -0
- package/contracts/ERC-3643/IERC3643IdentityRegistryStorage.sol +62 -7
- package/contracts/ERC-3643/IERC3643TrustedIssuersRegistry.sol +29 -12
- package/contracts/ERC-3643/base/ERC3643ClaimTopicsRegistry.sol +140 -0
- package/contracts/ERC-3643/base/ERC3643Compliance.sol +223 -0
- package/contracts/ERC-3643/base/ERC3643IdentityRegistry.sol +382 -0
- package/contracts/ERC-3643/base/ERC3643IdentityRegistryStorage.sol +290 -0
- package/contracts/ERC-3643/base/ERC3643Token.sol +601 -0
- package/contracts/ERC-3643/base/ERC3643TrustedIssuersRegistry.sol +237 -0
- package/contracts/compliance/modular/ComplianceLedger.sol +175 -0
- package/contracts/compliance/modular/ComplianceLedgerLib.sol +120 -0
- package/contracts/compliance/modular/IComplianceLedger.sol +104 -0
- package/contracts/compliance/modular/IModularCompliance.sol +119 -28
- package/contracts/compliance/modular/ITransferValidation.sol +308 -0
- package/contracts/compliance/modular/ModularCompliance.sol +399 -240
- package/contracts/compliance/modular/ModuleSetLib.sol +182 -0
- package/contracts/compliance/modular/MovementKindLib.sol +97 -0
- package/contracts/compliance/modular/TransferContextLib.sol +140 -0
- package/contracts/compliance/modular/TransferValidation.sol +822 -0
- package/contracts/compliance/modular/TransferValidationLib.sol +183 -0
- package/contracts/compliance/modular/modules/AbstractModuleUpgradeable.sol +87 -56
- package/contracts/compliance/modular/modules/IModule.sol +142 -58
- package/contracts/compliance/modular/modules/MaxBalancePerIdentityModule.sol +175 -0
- package/contracts/compliance/modular/modules/ModuleProxy.sol +24 -24
- package/contracts/compliance/modular/modules/SpenderVerificationModule.sol +149 -0
- package/contracts/compliance/modular/modules/SpenderWhitelistModule.sol +215 -0
- package/contracts/factory/ITREXFactory.sol +94 -44
- package/contracts/factory/TREXFactory.sol +408 -201
- package/contracts/interop/ISettlementHandler.sol +101 -0
- package/contracts/interop/ITREXMessaging.sol +166 -0
- package/contracts/{proxy/ModularComplianceProxy.sol → interop/ITrustedGatewayRegistry.sol} +48 -43
- package/contracts/interop/TREXMessaging.sol +189 -0
- package/contracts/interop/TREXMessagingLib.sol +425 -0
- package/contracts/{proxy/TrustedIssuersRegistryProxy.sol → interop/TrustedGatewayRegistry.sol} +46 -37
- package/contracts/libraries/AccessManagerSetupLib.sol +484 -0
- package/contracts/libraries/ErrorsLib.sol +172 -65
- package/contracts/libraries/EventsLib.sol +168 -66
- package/contracts/libraries/MessageTypesLib.sol +259 -0
- package/contracts/libraries/RolesLib.sol +146 -0
- package/contracts/{roles/Roles.sol → libraries/VersionLib.sol} +46 -49
- package/contracts/libraries/WalletKeyLib.sol +156 -0
- package/contracts/proxy/beacon/ITREXImplementationAuthority.sol +157 -0
- package/contracts/proxy/beacon/TREXImplementationAuthority.sol +188 -0
- package/contracts/registry/implementation/IdentityRegistryStorage.sol +215 -163
- package/contracts/registry/implementation/TREXRegistry.sol +475 -0
- package/contracts/registry/interface/IIdentityRegistryStorage.sol +30 -25
- package/contracts/registry/interface/ITREXRegistry.sol +180 -0
- package/contracts/token/IToken.sol +210 -49
- package/contracts/token/Token.sol +411 -476
- package/contracts/token/TokenDelegationLib.sol +339 -0
- package/contracts/token/TokenGuardsLib.sol +123 -0
- package/contracts/token/TokenLedgerLib.sol +316 -0
- package/contracts/token/TokenRecoveryLib.sol +130 -0
- package/contracts/{roles/AgentRoleUpgradeable.sol → utils/AccessManagedOwnable.sol} +31 -31
- package/contracts/{proxy/IdentityRegistryStorageProxy.sol → utils/AccessManagedOwnableBase.sol} +56 -34
- package/contracts/utils/AccessManagedOwnableUpgradeable.sol +116 -0
- package/contracts/utils/IUtilityChecker.sol +32 -26
- package/contracts/{roles/AbstractAgentRole.sol → utils/TREXAccessManager.sol} +54 -57
- package/contracts/utils/UtilityChecker.sol +175 -52
- package/contracts/utils/UtilityCheckerProxy.sol +24 -24
- package/contracts/{proxy/interface/IProxy.sol → vendor/IERC173.sol} +15 -28
- package/out/AbstractModuleUpgradeable.sol/AbstractModuleUpgradeable.json +1 -1
- package/out/AbstractSigner.sol/AbstractSigner.json +1 -0
- package/out/AccessManaged.sol/AccessManaged.json +1 -0
- package/out/AccessManagedOwnable.sol/AccessManagedOwnable.json +1 -0
- package/out/AccessManagedOwnableBase.sol/AccessManagedOwnableBase.json +1 -0
- package/out/AccessManagedOwnableUpgradeable.sol/AccessManagedOwnableUpgradeable.json +1 -0
- package/out/AccessManagedUpgradeable.sol/AccessManagedUpgradeable.json +1 -0
- package/out/AccessManager.sol/AccessManager.json +1 -0
- package/out/AccessManagerHelper.sol/AccessManagerHelper.json +1 -0
- package/out/AccessManagerSetupLib.sol/AccessManagerSetupLib.json +1 -0
- package/out/AccessManagerUpgradeable.sol/AccessManagerUpgradeable.json +1 -0
- package/out/Account.sol/Account.json +1 -0
- package/out/Address.sol/Address.json +1 -1
- package/out/Arrays.sol/Arrays.json +1 -1
- package/out/AuthorityUtils.sol/AuthorityUtils.json +1 -0
- package/out/Base.sol/CommonBase.json +1 -1
- package/out/Base.sol/ScriptBase.json +1 -1
- package/out/Base.sol/TestBase.json +1 -1
- package/out/Base64.sol/Base64.json +1 -0
- package/out/BeaconProxy.sol/BeaconProxy.json +1 -0
- package/out/BeaconProxyDeployer.sol/BeaconProxyDeployer.json +1 -0
- package/out/Bytes.sol/Bytes.json +1 -1
- package/out/Calldata.sol/Calldata.json +1 -0
- package/out/CapabilityModules.sol/AllTypesModule.json +1 -0
- package/out/CapabilityModules.sol/CappedRecipientModule.json +1 -0
- package/out/CapabilityModules.sol/DelegatedCapRuleModule.json +1 -0
- package/out/CapabilityModules.sol/DuplicateTypeModule.json +1 -0
- package/out/CapabilityModules.sol/LockedSenderModule.json +1 -0
- package/out/CapabilityModules.sol/NoTypeModule.json +1 -0
- package/out/CapabilityModules.sol/RecordingModule.json +1 -0
- package/out/CapabilityModules.sol/RuleAndMintTrackerModule.json +1 -0
- package/out/CapabilityModules.sol/RuleAndTrackerModule.json +1 -0
- package/out/CapabilityModules.sol/RuleOnlyModule.json +1 -0
- package/out/CapabilityModules.sol/SpenderOnlyModule.json +1 -0
- package/out/CapabilityModules.sol/TrackerOnlyModule.json +1 -0
- package/out/CapabilityModules.sol/UndeclaredRuleModule.json +1 -0
- package/out/CapabilityModules.sol/WritingRuleModule.json +1 -0
- package/out/ClaimIssuerAlwaysReverts.sol/ClaimIssuerAlwaysReverts.json +1 -0
- package/out/ClaimIssuerTrick.sol/ClaimIssuerTrick.json +1 -1
- package/out/Comparators.sol/Comparators.json +1 -1
- package/out/ComplianceLedger.sol/ComplianceLedger.json +1 -0
- package/out/ComplianceLedgerLib.sol/ComplianceLedgerLib.json +1 -0
- package/out/Context.sol/Context.json +1 -1
- package/out/ContextUpgradeable.sol/ContextUpgradeable.json +1 -1
- package/out/Countries.sol/Countries.json +1 -1
- package/out/Create2.sol/Create2.json +1 -1
- package/out/Create3.sol/Create3.json +1 -1
- package/out/DeployComplianceModules.s.sol/DeployComplianceModules.json +1 -0
- package/out/DeployComplianceModules.s.sol/ITokenCompliance.json +1 -0
- package/out/DeployUtilityChecker.s.sol/DeployUtilityChecker.json +1 -0
- package/out/ECDSA.sol/ECDSA.json +1 -1
- package/out/EIP712.sol/EIP712.json +1 -1
- package/out/EIP712Upgradeable.sol/EIP712Upgradeable.json +1 -1
- package/out/ERC165.sol/ERC165.json +1 -0
- package/out/ERC165Checker.sol/ERC165Checker.json +1 -0
- package/out/ERC165Upgradeable.sol/ERC165Upgradeable.json +1 -0
- package/out/ERC1967Proxy.sol/ERC1967Proxy.json +1 -1
- package/out/ERC1967Utils.sol/ERC1967Utils.json +1 -1
- package/out/ERC20.sol/ERC20.json +1 -1
- package/out/ERC20Pausable.sol/ERC20Pausable.json +1 -1
- package/out/ERC20PermitUpgradeable.sol/ERC20PermitUpgradeable.json +1 -1
- package/out/ERC20Upgradeable.sol/ERC20Upgradeable.json +1 -1
- package/out/ERC3643ClaimTopicsRegistry.sol/ERC3643ClaimTopicsRegistry.json +1 -0
- package/out/ERC3643Compliance.sol/ERC3643Compliance.json +1 -0
- package/out/ERC3643ErrorsLib.sol/ERC3643ErrorsLib.json +1 -0
- package/out/ERC3643IdentityRegistry.sol/ERC3643IdentityRegistry.json +1 -0
- package/out/ERC3643IdentityRegistryStorage.sol/ERC3643IdentityRegistryStorage.json +1 -0
- package/out/ERC3643Token.sol/ERC3643Token.json +1 -0
- package/out/ERC3643TrustedIssuersRegistry.sol/ERC3643TrustedIssuersRegistry.json +1 -0
- package/out/ERC4337Utils.sol/ERC4337Utils.json +1 -0
- package/out/ERC4337Utils.sol/IEntryPointExtra.json +1 -0
- package/out/ERC734Validator.sol/ERC734Validator.json +1 -0
- package/out/ERC7579Validator.sol/ERC7579Validator.json +1 -0
- package/out/ERC7786GatewayMock.sol/ERC7786GatewayMock.json +1 -0
- package/out/ERC7786Recipient.sol/ERC7786Recipient.json +1 -0
- package/out/ERC7913WebAuthnVerifier.sol/ERC7913WebAuthnVerifier.json +1 -0
- package/out/EnumerableSet.sol/EnumerableSet.json +1 -1
- package/out/Errors.sol/Errors.json +1 -1
- package/out/ErrorsLib.sol/ErrorsLib.json +1 -1
- package/out/EventsLib.sol/EventsLib.json +1 -1
- package/out/Hashes.sol/Hashes.json +1 -0
- package/out/HostileModules.sol/RevertEverywhereModule.json +1 -0
- package/out/HostileModules.sol/UnbindRevertingModule.json +1 -0
- package/out/IAccessManaged.sol/IAccessManaged.json +1 -0
- package/out/IAccessManager.sol/IAccessManager.json +1 -0
- package/out/IAuthority.sol/IAuthority.json +1 -0
- package/out/IBeacon.sol/IBeacon.json +1 -1
- package/out/IClaimIssuer.sol/IClaimIssuer.json +1 -1
- package/out/IComplianceLedger.sol/IComplianceLedger.json +1 -0
- package/out/IERC1271.sol/IERC1271.json +1 -0
- package/out/IERC165.sol/IERC165.json +1 -1
- package/out/IERC173.sol/IERC173.json +1 -1
- package/out/IERC1967.sol/IERC1967.json +1 -1
- package/out/IERC20.sol/IERC20.json +1 -1
- package/out/IERC20Metadata.sol/IERC20Metadata.json +1 -1
- package/out/IERC20Permit.sol/IERC20Permit.json +1 -1
- package/out/IERC3643.sol/IERC3643.json +1 -1
- package/out/IERC3643ClaimTopicsRegistry.sol/IERC3643ClaimTopicsRegistry.json +1 -1
- package/out/IERC3643Compliance.sol/IERC3643Compliance.json +1 -1
- package/out/IERC3643IdentityRegistry.sol/IERC3643IdentityRegistry.json +1 -1
- package/out/IERC3643IdentityRegistryStorage.sol/IERC3643IdentityRegistryStorage.json +1 -1
- package/out/IERC3643TrustedIssuersRegistry.sol/IERC3643TrustedIssuersRegistry.json +1 -1
- package/out/IERC4337.sol/IAccount.json +1 -0
- package/out/IERC4337.sol/IAccountExecute.json +1 -0
- package/out/IERC4337.sol/IAggregator.json +1 -0
- package/out/IERC4337.sol/IEntryPoint.json +1 -0
- package/out/IERC4337.sol/IEntryPointNonces.json +1 -0
- package/out/IERC4337.sol/IEntryPointStake.json +1 -0
- package/out/IERC4337.sol/IPaymaster.json +1 -0
- package/out/IERC5267.sol/IERC5267.json +1 -1
- package/out/IERC734.sol/IERC734.json +1 -1
- package/out/IERC735.sol/IERC735.json +1 -1
- package/out/IERC7913.sol/IERC7913SignatureVerifier.json +1 -0
- package/out/IIdentity.sol/IIdentity.json +1 -1
- package/out/IIdentityFactory.sol/IIdentityFactory.json +1 -0
- package/out/IIdentityRegistryStorage.sol/IIdentityRegistryStorage.json +1 -1
- package/out/IKeyExecutor.sol/IKeyExecutor.json +1 -0
- package/out/IModularCompliance.sol/IModularCompliance.json +1 -1
- package/out/IModule.sol/IModule.json +1 -1
- package/out/IMulticall3.sol/IMulticall3.json +1 -1
- package/out/IReputationRegistry.sol/IReputationRegistry.json +1 -0
- package/out/ISettlementHandler.sol/ISettlementHandler.json +1 -0
- package/out/ITREXFactory.sol/ITREXFactory.json +1 -1
- package/out/ITREXImplementationAuthority.sol/ITREXImplementationAuthority.json +1 -1
- package/out/ITREXMessaging.sol/ITREXMessaging.json +1 -0
- package/out/ITREXRegistry.sol/ITREXRegistry.json +1 -0
- package/out/IToken.sol/IToken.json +1 -1
- package/out/ITransferValidation.sol/ITransferValidation.json +1 -0
- package/out/ITrustedGatewayRegistry.sol/ITrustedGatewayRegistry.json +1 -0
- package/out/IUtilityChecker.sol/IUtilityChecker.json +1 -1
- package/out/Identity.sol/Identity.json +1 -1
- package/out/IdentityFactory.sol/IdentityFactory.json +1 -0
- package/out/IdentityModulesHelper.sol/IdentityModulesHelper.json +1 -0
- package/out/IdentityRegistryStorage.sol/IdentityRegistryStorage.json +1 -1
- package/out/IdentityTypes.sol/IdentityTypes.json +1 -0
- package/out/Initializable.sol/Initializable.json +1 -1
- package/out/InteropSuiteTest.sol/InteropSuiteTest.json +1 -0
- package/out/KeyApprovalModule.sol/IIdentityAccount.json +1 -0
- package/out/KeyApprovalModule.sol/KeyApprovalModule.json +1 -0
- package/out/KeyManager.sol/KeyManager.json +1 -0
- package/out/KeyPurposes.sol/KeyPurposes.json +1 -1
- package/out/KeyTypes.sol/KeyTypes.json +1 -1
- package/out/LowLevelCall.sol/LowLevelCall.json +1 -1
- package/out/Math.sol/Math.json +1 -1
- package/out/MaxBalancePerIdentityModule.sol/MaxBalancePerIdentityModule.json +1 -0
- package/out/MessageHashUtils.sol/MessageHashUtils.json +1 -1
- package/out/MessageTypesLib.sol/MessageTypesLib.json +1 -0
- package/out/MockTREXAccessManagerV2.sol/MockTREXAccessManagerV2.json +1 -0
- package/out/MockTokenV2.sol/MockTokenV2.json +1 -0
- package/out/Mocks.sol/ClaimTopicsRegistryMock.json +1 -0
- package/out/Mocks.sol/ComplianceMock.json +1 -0
- package/out/Mocks.sol/IdentityRegistryMock.json +1 -0
- package/out/Mocks.sol/IdentityRegistryStorageMock.json +1 -0
- package/out/Mocks.sol/TokenMock.json +1 -0
- package/out/Mocks.sol/TrustedIssuersRegistryMock.json +1 -0
- package/out/ModularCompliance.sol/ModularCompliance.json +1 -1
- package/out/ModuleNotPnP.sol/ModuleNotPnP.json +1 -1
- package/out/ModuleProxy.sol/ModuleProxy.json +1 -1
- package/out/ModuleSetLib.sol/ModuleSetLib.json +1 -0
- package/out/MovementKindLib.sol/MovementKindLib.json +1 -0
- package/out/Multicall.sol/Multicall.json +1 -0
- package/out/MulticallUpgradeable.sol/MulticallUpgradeable.json +1 -1
- package/out/Nonces.sol/Nonces.json +1 -1
- package/out/NoncesUpgradeable.sol/NoncesUpgradeable.json +1 -1
- package/out/Ownable.sol/Ownable.json +1 -1
- package/out/OwnableUpgradeable.sol/OwnableUpgradeable.json +1 -1
- package/out/P256.sol/P256.json +1 -0
- package/out/Packing.sol/Packing.json +1 -0
- package/out/Panic.sol/Panic.json +1 -1
- package/out/Pausable.sol/Pausable.json +1 -1
- package/out/PausableUpgradeable.sol/PausableUpgradeable.json +1 -1
- package/out/Proxy.sol/Proxy.json +1 -1
- package/out/ReentrancyGuardTransient.sol/ReentrancyGuardTransient.json +1 -0
- package/out/ReentrantModule.sol/ReentrantModule.json +1 -0
- package/out/ReputationRegistry.sol/ReputationRegistry.json +1 -0
- package/out/RolesLib.sol/RolesLib.json +1 -0
- package/out/SafeCalldataBatch.sol/SafeCalldataBatch.json +1 -0
- package/out/SafeCast.sol/SafeCast.json +1 -1
- package/out/SatelliteLiteMock.sol/SatelliteLiteMock.json +1 -0
- package/out/Script.sol/Script.json +1 -0
- package/out/ShortStrings.sol/ShortStrings.json +1 -1
- package/out/SignatureChecker.sol/SignatureChecker.json +1 -0
- package/out/SignedMath.sol/SignedMath.json +1 -1
- package/out/SlotDerivation.sol/SlotDerivation.json +1 -1
- package/out/SmartAccount.sol/SmartAccount.json +1 -0
- package/out/SpenderVerificationModule.sol/SpenderVerificationModule.json +1 -0
- package/out/SpenderWhitelistModule.sol/SpenderWhitelistModule.json +1 -0
- package/out/StdAssertions.sol/StdAssertions.json +1 -1
- package/out/StdChains.sol/StdChains.json +1 -1
- package/out/StdCheats.sol/StdCheats.json +1 -1
- package/out/StdCheats.sol/StdCheatsSafe.json +1 -1
- package/out/StdConstants.sol/StdConstants.json +1 -1
- package/out/StdError.sol/stdError.json +1 -1
- package/out/StdInvariant.sol/StdInvariant.json +1 -1
- package/out/StdJson.sol/stdJson.json +1 -1
- package/out/StdMath.sol/stdMath.json +1 -1
- package/out/StdStorage.sol/stdStorage.json +1 -1
- package/out/StdStorage.sol/stdStorageSafe.json +1 -1
- package/out/StdStyle.sol/StdStyle.json +1 -1
- package/out/StdToml.sol/stdToml.json +1 -1
- package/out/StdUtils.sol/StdUtils.json +1 -1
- package/out/StorageSlot.sol/StorageSlot.json +1 -1
- package/out/Strings.sol/Strings.json +1 -1
- package/out/Structs.sol/Structs.json +1 -1
- package/out/TREXAccessManager.sol/TREXAccessManager.json +1 -0
- package/out/TREXFactory.sol/TREXFactory.json +1 -1
- package/out/TREXImplementationAuthority.sol/TREXImplementationAuthority.json +1 -1
- package/out/TREXMessaging.sol/TREXMessaging.json +1 -0
- package/out/TREXMessagingLib.sol/TREXMessagingLib.json +1 -0
- package/out/TREXRegistry.sol/TREXRegistry.json +1 -0
- package/out/TestERC20.sol/TestERC20.json +1 -1
- package/out/TestModule.sol/TestModule.json +1 -1
- package/out/TestTREXFactory.sol/TestTREXFactory.json +1 -1
- package/out/Time.sol/Time.json +1 -0
- package/out/Token.sol/Token.json +1 -1
- package/out/TokenDelegationLib.sol/TokenDelegationLib.json +1 -0
- package/out/TokenGuardsLib.sol/TokenGuardsLib.json +1 -0
- package/out/TokenHandler.sol/TokenHandler.json +1 -0
- package/out/TokenLedgerHarness.sol/TokenLedgerHarness.json +1 -0
- package/out/TokenLedgerLib.sol/TokenLedgerLib.json +1 -0
- package/out/TokenRecoveryLib.sol/TokenRecoveryLib.json +1 -0
- package/out/TokenReservationStub.sol/TokenReservationStub.json +1 -0
- package/out/TransferContextLib.sol/TransferContextLib.json +1 -0
- package/out/TransferValidation.sol/TransferValidation.json +1 -0
- package/out/TransferValidationHarness.sol/TransferValidationHarness.json +1 -0
- package/out/TransferValidationLib.sol/TransferValidationLib.json +1 -0
- package/out/TransientSlot.sol/TransientSlot.json +1 -0
- package/out/TrustedGatewayRegistry.sol/TrustedGatewayRegistry.json +1 -0
- package/out/UUPSUpgradeable.sol/UUPSUpgradeable.json +1 -1
- package/out/UpgradeableBeacon.sol/UpgradeableBeacon.json +1 -0
- package/out/UtilityChecker.sol/UtilityChecker.json +1 -1
- package/out/UtilityCheckerProxy.sol/UtilityCheckerProxy.json +1 -1
- package/out/Utils.sol/Utils.json +1 -1
- package/out/VersionLib.sol/VersionLib.json +1 -0
- package/out/Vm.sol/Vm.json +1 -1
- package/out/Vm.sol/VmSafe.json +1 -1
- package/out/WalletKeyLib.sol/WalletKeyLib.json +1 -0
- package/out/WebAuthn.sol/WebAuthn.json +1 -0
- package/out/console.sol/console.json +1 -1
- package/out/draft-AccountERC7579Upgradeable.sol/AccountERC7579Upgradeable.json +1 -0
- package/out/draft-ERC7579Utils.sol/ERC7579Utils.json +1 -0
- package/out/draft-IERC1822.sol/IERC1822Proxiable.json +1 -1
- package/out/draft-IERC6093.sol/IERC1155Errors.json +1 -1
- package/out/draft-IERC6093.sol/IERC20Errors.json +1 -1
- package/out/draft-IERC6093.sol/IERC721Errors.json +1 -1
- package/out/draft-IERC7579.sol/IERC7579AccountConfig.json +1 -0
- package/out/draft-IERC7579.sol/IERC7579Execution.json +1 -0
- package/out/draft-IERC7579.sol/IERC7579Hook.json +1 -0
- package/out/draft-IERC7579.sol/IERC7579Module.json +1 -0
- package/out/draft-IERC7579.sol/IERC7579ModuleConfig.json +1 -0
- package/out/draft-IERC7579.sol/IERC7579Validator.json +1 -0
- package/out/draft-IERC7786.sol/IERC7786GatewaySource.json +1 -0
- package/out/draft-IERC7786.sol/IERC7786Recipient.json +1 -0
- package/out/draft-InteroperableAddress.sol/InteroperableAddress.json +1 -0
- package/out/libraries/Errors.sol/Errors.json +1 -1
- package/out/safeconsole.sol/safeconsole.json +1 -1
- package/package.json +11 -7
- package/contracts/ERC-3643/ERC3643EventsLib.sol +0 -150
- package/contracts/factory/ITREXGateway.sol +0 -234
- package/contracts/factory/TREXGateway.sol +0 -274
- package/contracts/proxy/AbstractProxy.sol +0 -146
- package/contracts/proxy/ClaimTopicsRegistryProxy.sol +0 -83
- package/contracts/proxy/IdentityRegistryProxy.sol +0 -95
- package/contracts/proxy/TokenProxy.sol +0 -97
- package/contracts/proxy/authority/IAFactory.sol +0 -122
- package/contracts/proxy/authority/IIAFactory.sol +0 -87
- package/contracts/proxy/authority/ITREXImplementationAuthority.sol +0 -239
- package/contracts/proxy/authority/TREXImplementationAuthority.sol +0 -350
- package/contracts/registry/implementation/ClaimTopicsRegistry.sol +0 -152
- package/contracts/registry/implementation/IdentityRegistry.sol +0 -352
- package/contracts/registry/implementation/TrustedIssuersRegistry.sol +0 -272
- package/contracts/registry/interface/IClaimTopicsRegistry.sol +0 -70
- package/contracts/registry/interface/IIdentityRegistry.sol +0 -102
- package/contracts/registry/interface/ITrustedIssuersRegistry.sol +0 -70
- package/contracts/roles/IERC173.sol +0 -21
- package/contracts/token/TokenStructs.sol +0 -74
- package/contracts/utils/InterfaceIdCalculator.sol +0 -223
- package/contracts/vendor/openzeppelin/Create3.sol +0 -143
- package/out/AbstractAgentRole.sol/AbstractAgentRole.json +0 -1
- package/out/AbstractProxy.sol/AbstractProxy.json +0 -1
- package/out/AgentRole.sol/AgentRole.json +0 -1
- package/out/AgentRoleUpgradeable.sol/AgentRoleUpgradeable.json +0 -1
- package/out/ClaimIssuer.sol/ClaimIssuer.json +0 -1
- package/out/ClaimTopicsRegistry.sol/ClaimTopicsRegistry.json +0 -1
- package/out/ClaimTopicsRegistryProxy.sol/ClaimTopicsRegistryProxy.json +0 -1
- package/out/ERC2771Context.sol/ERC2771Context.json +0 -1
- package/out/ERC2771ContextUpgradeable.sol/ERC2771ContextUpgradeable.json +0 -1
- package/out/ERC2771Forwarder.sol/ERC2771Forwarder.json +0 -1
- package/out/ERC3643EventsLib.sol/ERC3643EventsLib.json +0 -1
- package/out/IAFactory.sol/IAFactory.json +0 -1
- package/out/IClaimTopicsRegistry.sol/IClaimTopicsRegistry.json +0 -1
- package/out/IERC1363.sol/IERC1363.json +0 -1
- package/out/IIAFactory.sol/IIAFactory.json +0 -1
- package/out/IIdFactory.sol/IIdFactory.json +0 -1
- package/out/IIdentityRegistry.sol/IIdentityRegistry.json +0 -1
- package/out/IImplementationAuthority.sol/IImplementationAuthority.json +0 -1
- package/out/IProxy.sol/IProxy.json +0 -1
- package/out/ITREXGateway.sol/ITREXGateway.json +0 -1
- package/out/ITrustedIssuersRegistry.sol/ITrustedIssuersRegistry.json +0 -1
- package/out/IdFactory.sol/IdFactory.json +0 -1
- package/out/IdentityProxy.sol/IdentityProxy.json +0 -1
- package/out/IdentityRegistry.sol/IdentityRegistry.json +0 -1
- package/out/IdentityRegistryProxy.sol/IdentityRegistryProxy.json +0 -1
- package/out/IdentityRegistryStorageProxy.sol/IdentityRegistryStorageProxy.json +0 -1
- package/out/ImplementationAuthority.sol/ImplementationAuthority.json +0 -1
- package/out/InterfaceIdCalculator.sol/InterfaceIdCalculator.json +0 -1
- package/out/ModularComplianceProxy.sol/ModularComplianceProxy.json +0 -1
- package/out/Ownable2Step.sol/Ownable2Step.json +0 -1
- package/out/Ownable2StepUpgradeable.sol/Ownable2StepUpgradeable.json +0 -1
- package/out/Roles.sol/Roles.json +0 -1
- package/out/SafeERC20.sol/SafeERC20.json +0 -1
- package/out/Storage.sol/Storage.json +0 -1
- package/out/TREXGateway.sol/TREXGateway.json +0 -1
- package/out/TestAgentRole.sol/TestAgentRole.json +0 -1
- package/out/TestAgentRoleUpgradeable.sol/TestAgentRoleUpgradeable.json +0 -1
- package/out/TokenProxy.sol/TokenProxy.json +0 -1
- package/out/TrustedIssuersRegistry.sol/TrustedIssuersRegistry.json +0 -1
- package/out/TrustedIssuersRegistryProxy.sol/TrustedIssuersRegistryProxy.json +0 -1
- package/out/Version.sol/Version.json +0 -1
|
@@ -0,0 +1,316 @@
|
|
|
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 { IERC20Errors } from "@openzeppelin/contracts/interfaces/draft-IERC6093.sol";
|
|
63
|
+
|
|
64
|
+
import { ErrorsLib } from "../libraries/ErrorsLib.sol";
|
|
65
|
+
import { EventsLib } from "../libraries/EventsLib.sol";
|
|
66
|
+
import { WalletKeyLib } from "../libraries/WalletKeyLib.sol";
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @title TokenLedgerLib
|
|
70
|
+
* @dev The token's bridged ledger, deployed once and linked.
|
|
71
|
+
*
|
|
72
|
+
* Satellite positions, in-transit holds and validation reservations are envelope parsing and bucket
|
|
73
|
+
* arithmetic: bytecode that pushed the token past EIP-170. It lives here and the token reaches it by
|
|
74
|
+
* DELEGATECALL, so the storage is the token's own `erc3643.storage.TREXToken` namespace at the slot it
|
|
75
|
+
* always had, `block.chainid` and `address(this)` are the token's, and every event is the token's.
|
|
76
|
+
*
|
|
77
|
+
* Nothing here is an entry point and nothing checks a caller or the pause: the token's entry points do,
|
|
78
|
+
* before they reach this. The native half of a movement is not here either, since it is the ERC-20
|
|
79
|
+
* balance the library cannot reach: the token burns or mints it around the call. Its state-changing
|
|
80
|
+
* functions cannot be called on the library itself.
|
|
81
|
+
*/
|
|
82
|
+
library TokenLedgerLib {
|
|
83
|
+
|
|
84
|
+
/// @custom:storage-location erc7201:erc3643.storage.TREXToken
|
|
85
|
+
struct TokenStorage {
|
|
86
|
+
uint8 decimals;
|
|
87
|
+
/// @dev Positions delegated to satellites, keyed by the canonical ERC-7930 wallet key. Separate from the
|
|
88
|
+
/// native mapping, which stays OpenZeppelin's.
|
|
89
|
+
mapping(bytes32 walletKey => uint256) bridgedBalance;
|
|
90
|
+
/// @dev Sum of every bridged position, kept so `totalSupply` counts it in O(1).
|
|
91
|
+
uint256 totalBridged;
|
|
92
|
+
/// @dev Amounts a satellite burned for a cross-chain validation whose mint leg has not landed, keyed by
|
|
93
|
+
/// the validation. Debited from the sender's position, still counted in `totalBridged`, still owned by
|
|
94
|
+
/// the sender the validation names.
|
|
95
|
+
mapping(uint256 validationId => uint256) inTransit;
|
|
96
|
+
/// @dev Sum of every in-transit hold: the part of `totalBridged` no wallet currently holds.
|
|
97
|
+
uint256 totalInTransit;
|
|
98
|
+
/// @dev What open validations may still draw from each satellite wallet. Kept here, beside the balance
|
|
99
|
+
/// it reserves against, so `availableOf` is one subtraction rather than two contracts agreeing: the
|
|
100
|
+
/// compliance reserves at issuance and gives back at settlement or discard, and `holdInTransit` turns a
|
|
101
|
+
/// reservation straight into a hold, which is why nothing has to be released in between.
|
|
102
|
+
mapping(bytes32 walletKey => uint256) reservedForValidations;
|
|
103
|
+
/// @dev Recall instructions waiting for their proof, keyed by id. A settling proof deletes its record.
|
|
104
|
+
mapping(uint256 recallId => PendingRecall) recalls;
|
|
105
|
+
/// @dev The last recall id issued. Ids start at 1.
|
|
106
|
+
uint256 lastRecallId;
|
|
107
|
+
/// @dev The one recall open on each satellite wallet, zero when none.
|
|
108
|
+
mapping(bytes32 walletKey => uint256 recallId) openRecall;
|
|
109
|
+
/// @dev `keccak256(abi.encode(originChainKey, body))` of the proof that settled each recall, kept after the
|
|
110
|
+
/// record is gone so the same proof delivered again is recognised as a duplicate, not a replay.
|
|
111
|
+
mapping(uint256 recallId => bytes32) settledProofs;
|
|
112
|
+
/// @dev The last delegation id issued. Ids start at 1.
|
|
113
|
+
uint256 lastDelegationId;
|
|
114
|
+
/// @dev `keccak256(abi.encode(chainKey, peerKey, toWallet, amount, holder))` of each delegation's mint
|
|
115
|
+
/// instruction, so a resend can prove it repeats it exactly.
|
|
116
|
+
mapping(uint256 delegationId => bytes32) delegations;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/// @dev What a burn proof is matched against, and where it may come from: the wallet and chain the recall
|
|
120
|
+
/// named, the native wallet it credits, the ceiling on what the satellite may prove, and the gateway and
|
|
121
|
+
/// peer it was dispatched to. `gateway` and `peerKey` come last so the layout before them is unchanged.
|
|
122
|
+
struct PendingRecall {
|
|
123
|
+
bytes32 walletKey;
|
|
124
|
+
bytes32 chainKey;
|
|
125
|
+
address nativeWallet;
|
|
126
|
+
uint256 amount;
|
|
127
|
+
address gateway;
|
|
128
|
+
bytes32 peerKey;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// keccak256(abi.encode(uint256(keccak256("erc3643.storage.TREXToken")) - 1)) & ~bytes32(uint256(0xff));
|
|
132
|
+
bytes32 private constant TOKEN_STORAGE_LOCATION =
|
|
133
|
+
0x05378669fd58b6f9251e6d5461e60e18b8b3fdf11d70481ba6f9fc72a4bfc600;
|
|
134
|
+
|
|
135
|
+
/* ----- Views ----- */
|
|
136
|
+
|
|
137
|
+
/// @dev See {IToken-bridgedBalanceOf}.
|
|
138
|
+
function bridgedBalanceOf(bytes calldata wallet) external view returns (uint256) {
|
|
139
|
+
return layout().bridgedBalance[WalletKeyLib.canonicalKey(wallet)];
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/// @dev See {IToken-reservedOf}.
|
|
143
|
+
function reservedOf(bytes calldata wallet) external view returns (uint256) {
|
|
144
|
+
return layout().reservedForValidations[WalletKeyLib.canonicalKey(wallet)];
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/// @dev See {IToken-availableOf}.
|
|
148
|
+
function availableOf(bytes calldata wallet) external view returns (uint256) {
|
|
149
|
+
TokenStorage storage s = layout();
|
|
150
|
+
bytes32 key = WalletKeyLib.canonicalKey(wallet);
|
|
151
|
+
uint256 balance = s.bridgedBalance[key];
|
|
152
|
+
uint256 reserved = s.reservedForValidations[key];
|
|
153
|
+
return reserved < balance ? balance - reserved : 0;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/* ----- Reservations ----- */
|
|
157
|
+
|
|
158
|
+
/// @dev Records that an open validation may draw `amount` from a satellite `wallet`.
|
|
159
|
+
function reserve(bytes calldata wallet, uint256 amount) external {
|
|
160
|
+
bytes32 key = WalletKeyLib.satelliteKey(wallet);
|
|
161
|
+
layout().reservedForValidations[key] += amount;
|
|
162
|
+
|
|
163
|
+
emit EventsLib.ReservedForValidation(key, wallet, amount);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/// @dev Gives back what a validation reserved against `wallet`. See {_release}.
|
|
167
|
+
function release(bytes calldata wallet, uint256 amount) external {
|
|
168
|
+
_release(WalletKeyLib.canonicalKey(wallet), wallet, amount);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/* ----- Transitions ----- */
|
|
172
|
+
|
|
173
|
+
/// @dev Takes `amount` out of `fromWallet`'s bridged position and holds it against `validationId`: the burn
|
|
174
|
+
/// leg of a cross-chain validation landed, the mint leg has not. The amount stays bridged and stays the
|
|
175
|
+
/// sender's; only the wallet no longer holds it, so nothing can be issued or recalled against tokens the
|
|
176
|
+
/// satellite already burned. One hold per validation.
|
|
177
|
+
/// @dev Turns what a validation reserved against the wallet into an in-transit hold, in one step: the
|
|
178
|
+
/// tokens leave the wallet, so the reservation that was standing in for them is given back at the same
|
|
179
|
+
/// time and there is nothing to release separately.
|
|
180
|
+
/// @param reserved what this validation had reserved against the wallet, released as the hold is taken
|
|
181
|
+
function holdInTransit(bytes calldata fromWallet, uint256 amount, uint256 validationId, uint256 reserved) external {
|
|
182
|
+
bytes32 fromKey = WalletKeyLib.satelliteKey(fromWallet);
|
|
183
|
+
|
|
184
|
+
TokenStorage storage s = layout();
|
|
185
|
+
require(s.inTransit[validationId] == 0, ErrorsLib.TransitAlreadyHeld(validationId));
|
|
186
|
+
if (reserved != 0) _release(fromKey, fromWallet, reserved);
|
|
187
|
+
_debit(s, fromWallet, fromKey, amount);
|
|
188
|
+
s.inTransit[validationId] = amount;
|
|
189
|
+
s.totalInTransit += amount;
|
|
190
|
+
|
|
191
|
+
emit EventsLib.HeldInTransit(fromKey, validationId, fromWallet, amount);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/// @dev Puts a held amount back on the wallet it was burned from. The mirror of {holdInTransit}: the
|
|
195
|
+
/// movement is unwound where it started instead of completed, so `totalSupply` and `totalBridged` do not
|
|
196
|
+
/// move, only the hold becomes a balance again.
|
|
197
|
+
function returnHeldInTransit(bytes calldata toWallet, uint256 validationId) external {
|
|
198
|
+
TokenStorage storage s = layout();
|
|
199
|
+
uint256 held = s.inTransit[validationId];
|
|
200
|
+
require(held != 0, ErrorsLib.NothingInTransit(validationId));
|
|
201
|
+
|
|
202
|
+
bytes32 toKey = WalletKeyLib.satelliteKey(toWallet);
|
|
203
|
+
delete s.inTransit[validationId];
|
|
204
|
+
s.totalInTransit -= held;
|
|
205
|
+
s.bridgedBalance[toKey] += held;
|
|
206
|
+
|
|
207
|
+
emit EventsLib.ReturnedInTransit(toKey, validationId, toWallet, held);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/// @dev Routes a settled validation leg. A receiver on this chain is the token's to credit, so only the
|
|
211
|
+
/// bridged half is applied here: the sender's position is debited and `toNative` tells the token to mint
|
|
212
|
+
/// `amount` to `recipient` and name the movement. Any other receiver is a movement between two satellite
|
|
213
|
+
/// wallets and is applied whole, see {_bridgedTransfer}.
|
|
214
|
+
/// @return toNative Whether the receiver is a wallet on this chain.
|
|
215
|
+
/// @return recipient That wallet, when `toNative`.
|
|
216
|
+
/// @return fromKey The sender's key, when `toNative`.
|
|
217
|
+
function settle(bytes calldata from, bytes calldata to, uint256 amount, uint256 validationId)
|
|
218
|
+
external
|
|
219
|
+
returns (bool toNative, address recipient, bytes32 fromKey)
|
|
220
|
+
{
|
|
221
|
+
(toNative, recipient) = WalletKeyLib.isReferenceChain(to);
|
|
222
|
+
if (toNative) {
|
|
223
|
+
fromKey = _debitToNative(from, recipient, amount);
|
|
224
|
+
} else {
|
|
225
|
+
_bridgedTransfer(from, to, amount, validationId);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/// @dev The bridged half of every bridged-to-native transition: a bridged debit, `totalBridged` down. The
|
|
230
|
+
/// token mints `amount` to `holder` afterwards and names the movement. Emits nothing.
|
|
231
|
+
function debitToNative(bytes calldata fromWallet, address holder, uint256 amount)
|
|
232
|
+
external
|
|
233
|
+
returns (bytes32 fromKey)
|
|
234
|
+
{
|
|
235
|
+
return _debitToNative(fromWallet, holder, amount);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/// @dev The bridged half of every native-to-bridged transition: a bridged credit, `totalBridged` up. The
|
|
239
|
+
/// token burns `amount` from `holder` afterwards and names the movement. Emits nothing.
|
|
240
|
+
/// @param freeBalance `holder`'s free native balance, read by the token; `amount` may not exceed it
|
|
241
|
+
function creditFromNative(address holder, bytes calldata toWallet, uint256 amount, uint256 freeBalance)
|
|
242
|
+
external
|
|
243
|
+
returns (bytes32 toKey)
|
|
244
|
+
{
|
|
245
|
+
toKey = WalletKeyLib.satelliteKey(toWallet);
|
|
246
|
+
require(amount <= freeBalance, IERC20Errors.ERC20InsufficientBalance(holder, freeBalance, amount));
|
|
247
|
+
|
|
248
|
+
TokenStorage storage s = layout();
|
|
249
|
+
s.bridgedBalance[toKey] += amount;
|
|
250
|
+
s.totalBridged += amount;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/* ----- Storage ----- */
|
|
254
|
+
|
|
255
|
+
/// @dev The token's `TREXToken` namespace. Internal, so the cheap reads stay in the token itself.
|
|
256
|
+
function layout() internal pure returns (TokenStorage storage $) {
|
|
257
|
+
assembly ("memory-safe") {
|
|
258
|
+
$.slot := TOKEN_STORAGE_LOCATION
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/* ----- Private ----- */
|
|
263
|
+
|
|
264
|
+
/// @dev Applies a settled movement between two satellite wallets, same-chain or cross-chain, in one atomic
|
|
265
|
+
/// touch: `from` down, `to` up, nothing native. `validationId` is the validation the settlement consumed.
|
|
266
|
+
/// When its burn leg already moved the amount in transit, the hold is what `to` is credited from, and it
|
|
267
|
+
/// must be the settled amount exactly.
|
|
268
|
+
function _bridgedTransfer(bytes calldata from, bytes calldata to, uint256 amount, uint256 validationId) private {
|
|
269
|
+
bytes32 fromKey = WalletKeyLib.satelliteKey(from);
|
|
270
|
+
bytes32 toKey = WalletKeyLib.satelliteKey(to);
|
|
271
|
+
|
|
272
|
+
TokenStorage storage s = layout();
|
|
273
|
+
uint256 held = s.inTransit[validationId];
|
|
274
|
+
if (held != 0) {
|
|
275
|
+
require(held == amount, ErrorsLib.TransitAmountMismatch(validationId, held, amount));
|
|
276
|
+
delete s.inTransit[validationId];
|
|
277
|
+
s.totalInTransit -= amount;
|
|
278
|
+
} else {
|
|
279
|
+
_debit(s, from, fromKey, amount);
|
|
280
|
+
}
|
|
281
|
+
s.bridgedBalance[toKey] += amount;
|
|
282
|
+
|
|
283
|
+
emit EventsLib.BridgedTransfer(fromKey, toKey, validationId, from, to, amount);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function _debitToNative(bytes calldata fromWallet, address holder, uint256 amount)
|
|
287
|
+
private
|
|
288
|
+
returns (bytes32 fromKey)
|
|
289
|
+
{
|
|
290
|
+
require(holder != address(0), ErrorsLib.ZeroAddress());
|
|
291
|
+
fromKey = WalletKeyLib.satelliteKey(fromWallet);
|
|
292
|
+
|
|
293
|
+
TokenStorage storage s = layout();
|
|
294
|
+
_debit(s, fromWallet, fromKey, amount);
|
|
295
|
+
s.totalBridged -= amount;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/// @dev Gives back what a validation reserved against a wallet. Floors at zero rather than reverting: the
|
|
299
|
+
/// compliance is the only caller and releases each reservation once, so a shortfall would mean its own
|
|
300
|
+
/// bookkeeping is wrong, and blocking a settlement over it would strand the movement.
|
|
301
|
+
function _release(bytes32 key, bytes calldata wallet, uint256 amount) private {
|
|
302
|
+
mapping(bytes32 => uint256) storage reserved = layout().reservedForValidations;
|
|
303
|
+
uint256 held = reserved[key];
|
|
304
|
+
uint256 released = held < amount ? held : amount;
|
|
305
|
+
reserved[key] = held - released;
|
|
306
|
+
|
|
307
|
+
emit EventsLib.ReleasedFromValidation(key, wallet, released);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function _debit(TokenStorage storage s, bytes calldata wallet, bytes32 key, uint256 amount) private {
|
|
311
|
+
uint256 balance = s.bridgedBalance[key];
|
|
312
|
+
require(amount <= balance, ErrorsLib.InsufficientBridgedBalance(wallet, balance, amount));
|
|
313
|
+
s.bridgedBalance[key] = balance - amount;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
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 { IIdentity } from "@onchain-id/solidity/contracts/interface/IIdentity.sol";
|
|
63
|
+
|
|
64
|
+
import { IERC3643IdentityRegistry } from "../ERC-3643/IERC3643IdentityRegistry.sol";
|
|
65
|
+
import { ErrorsLib } from "../libraries/ErrorsLib.sol";
|
|
66
|
+
import { ITREXRegistry } from "../registry/interface/ITREXRegistry.sol";
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @title TokenRecoveryLib
|
|
70
|
+
* @dev The registry side of the token's wallet recovery, deployed once and linked.
|
|
71
|
+
*
|
|
72
|
+
* Recovery is rare and its registry conversation is external calls and ABI encoding the token would
|
|
73
|
+
* otherwise carry on every deployment. The token reaches this by DELEGATECALL, so the registry sees the
|
|
74
|
+
* token as its caller, exactly as before. The balance and freeze migration stays in the token, since it
|
|
75
|
+
* is the token's own ERC-20 and ERC-3643 state.
|
|
76
|
+
*/
|
|
77
|
+
library TokenRecoveryLib {
|
|
78
|
+
|
|
79
|
+
/// @dev The T-REX recovery preconditions: a wallet may not be recovered onto itself, there must be
|
|
80
|
+
/// something to recover, at least one of the two wallets must already be known to the registry, and each
|
|
81
|
+
/// known wallet must belong to `investorOnchainId`. Reverts in that order.
|
|
82
|
+
/// @dev Recovery moves one investor's tokens between that investor's wallets. Without the lost-wallet check
|
|
83
|
+
/// an agent could name another identity: the tokens would land in a wallet registered to it, skipping the
|
|
84
|
+
/// verification a forced transfer requires and reported to the compliance as a recovery, and the registry
|
|
85
|
+
/// would map the new wallet through the token's own AGENT grant. A wallet never changes identity. To move an
|
|
86
|
+
/// investor to a new identity, register a wallet of that identity and force transfer to it.
|
|
87
|
+
/// @param lostBalance the lost wallet's current balance, read by the token
|
|
88
|
+
function checkRecovery(
|
|
89
|
+
IERC3643IdentityRegistry registry,
|
|
90
|
+
address lostWallet,
|
|
91
|
+
address newWallet,
|
|
92
|
+
address investorOnchainId,
|
|
93
|
+
uint256 lostBalance
|
|
94
|
+
) external view {
|
|
95
|
+
require(lostWallet != newWallet, ErrorsLib.SameWalletRecovery());
|
|
96
|
+
require(lostBalance != 0, ErrorsLib.NoTokenToRecover());
|
|
97
|
+
|
|
98
|
+
require(registry.contains(lostWallet) || registry.contains(newWallet), ErrorsLib.RecoveryNotPossible());
|
|
99
|
+
require(
|
|
100
|
+
!registry.contains(lostWallet) || registry.identity(lostWallet) == IIdentity(investorOnchainId),
|
|
101
|
+
ErrorsLib.RecoveryNotPossible()
|
|
102
|
+
);
|
|
103
|
+
require(
|
|
104
|
+
!registry.contains(newWallet) || registry.identity(newWallet) == IIdentity(investorOnchainId),
|
|
105
|
+
ErrorsLib.RecoveryNotPossible()
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/// @dev The new wallet is registered only when it resolves nowhere, so a wallet the global registry
|
|
110
|
+
/// already binds keeps following that binding rather than a local copy. The lost wallet is reported for deletion
|
|
111
|
+
/// only when it is active in the local storage. Country is
|
|
112
|
+
/// passed as 0 rather than read from the lost wallet, because T-REX stores none.
|
|
113
|
+
/// @dev The new wallet must then pass `isVerified`, as the recipient of a forced transfer must: a wallet
|
|
114
|
+
/// revoked in ONCHAINID keeps its binding, and could otherwise receive the balance and move it out. The
|
|
115
|
+
/// check runs after the registration so that a fresh wallet is judged on the identity's claims.
|
|
116
|
+
/// @return lostWalletLocal whether the token must delete the lost wallet once compliance has been told
|
|
117
|
+
function registerRecoveredWallet(
|
|
118
|
+
IERC3643IdentityRegistry registry,
|
|
119
|
+
address lostWallet,
|
|
120
|
+
address newWallet,
|
|
121
|
+
address investorOnchainId
|
|
122
|
+
) external returns (bool lostWalletLocal) {
|
|
123
|
+
if (!registry.contains(newWallet)) {
|
|
124
|
+
registry.registerIdentity(newWallet, IIdentity(investorOnchainId), 0);
|
|
125
|
+
}
|
|
126
|
+
require(registry.isVerified(newWallet), ErrorsLib.UnverifiedIdentity());
|
|
127
|
+
return ITREXRegistry(address(registry)).isLocallyRegistered(lostWallet);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
}
|
|
@@ -37,46 +37,46 @@
|
|
|
37
37
|
// :#%%=
|
|
38
38
|
//
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
*
|
|
60
|
-
* You should have received a copy of the GNU General Public License
|
|
61
|
-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
62
|
-
*/
|
|
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/>.
|
|
63
59
|
|
|
64
60
|
pragma solidity 0.8.30;
|
|
65
61
|
|
|
66
|
-
import {
|
|
62
|
+
import { AccessManaged } from "@openzeppelin/contracts/access/manager/AccessManaged.sol";
|
|
67
63
|
|
|
68
|
-
import {
|
|
64
|
+
import { AccessManagedOwnableBase } from "./AccessManagedOwnableBase.sol";
|
|
69
65
|
|
|
70
|
-
contract
|
|
66
|
+
abstract contract AccessManagedOwnable is AccessManaged, AccessManagedOwnableBase {
|
|
71
67
|
|
|
72
|
-
constructor()
|
|
68
|
+
constructor(address initialAuthority) AccessManaged(initialAuthority) { }
|
|
73
69
|
|
|
74
|
-
|
|
75
|
-
|
|
70
|
+
/// @inheritdoc AccessManagedOwnableBase
|
|
71
|
+
function authority() public view virtual override(AccessManaged, AccessManagedOwnableBase) returns (address) {
|
|
72
|
+
return super.authority();
|
|
76
73
|
}
|
|
77
74
|
|
|
78
|
-
|
|
79
|
-
|
|
75
|
+
/// @dev Every owner change passes here: the constructor and the manager's `updateAuthority`. ERC-173 requires
|
|
76
|
+
/// `OwnershipTransferred` on each, including creation, where the previous owner is the zero address.
|
|
77
|
+
function _setAuthority(address newAuthority) internal virtual override {
|
|
78
|
+
emit OwnershipTransferred(authority(), newAuthority);
|
|
79
|
+
super._setAuthority(newAuthority);
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
}
|
package/contracts/{proxy/IdentityRegistryStorageProxy.sol → utils/AccessManagedOwnableBase.sol}
RENAMED
|
@@ -36,48 +36,70 @@
|
|
|
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
|
|
|
62
|
+
import { IAccessManaged } from "@openzeppelin/contracts/access/manager/IAccessManaged.sol";
|
|
63
|
+
import { ERC165 } from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
|
|
64
|
+
|
|
65
65
|
import { ErrorsLib } from "../libraries/ErrorsLib.sol";
|
|
66
|
-
import {
|
|
67
|
-
import { AbstractProxy } from "./AbstractProxy.sol";
|
|
68
|
-
import { ITREXImplementationAuthority } from "./authority/ITREXImplementationAuthority.sol";
|
|
66
|
+
import { IERC173 } from "../vendor/IERC173.sol";
|
|
69
67
|
|
|
70
|
-
|
|
68
|
+
/// @dev Shared IERC173 ownership surface layered on top of an AccessManager-backed authority.
|
|
69
|
+
/// Concrete contracts mix this with either `AccessManaged` or `AccessManagedUpgradeable`,
|
|
70
|
+
/// which supply `authority()`.
|
|
71
|
+
abstract contract AccessManagedOwnableBase is IERC173, ERC165 {
|
|
71
72
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
{
|
|
75
|
-
(
|
|
76
|
-
|
|
73
|
+
/// @dev Misconfiguration guard, NOT a trust boundary: `other.authority()` is spoofable, so always
|
|
74
|
+
/// pair with `restricted`. Only the `other != address(0)` clause is not spoofable.
|
|
75
|
+
modifier onlySharedAuthority(address other) {
|
|
76
|
+
_checkSharedAuthority(other);
|
|
77
|
+
_;
|
|
77
78
|
}
|
|
78
79
|
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
/// @inheritdoc IERC173
|
|
81
|
+
/// @dev Always reverts. The owner is the AccessManager, and a change of manager must wait for the target's
|
|
82
|
+
/// admin delay, which the manager applies only to its own `updateAuthority`. This function is a
|
|
83
|
+
/// call on the target itself, mapped to no role, so the manager would run it with no delay.
|
|
84
|
+
function transferOwnership(address) external pure {
|
|
85
|
+
revert ErrorsLib.UseUpdateAuthority();
|
|
81
86
|
}
|
|
82
87
|
|
|
88
|
+
/// @inheritdoc IERC173
|
|
89
|
+
function owner() external view returns (address) {
|
|
90
|
+
return authority();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/// @inheritdoc ERC165
|
|
94
|
+
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
|
|
95
|
+
return interfaceId == type(IERC173).interfaceId || super.supportsInterface(interfaceId);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function _checkSharedAuthority(address other) internal view {
|
|
99
|
+
require(other != address(0) && IAccessManaged(other).authority() == authority(), ErrorsLib.AuthorityMismatch());
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/// @dev Supplied by the concrete AccessManaged base (upgradeable or not).
|
|
103
|
+
function authority() public view virtual returns (address);
|
|
104
|
+
|
|
83
105
|
}
|