diff --git a/packages/ats/contracts/contracts/factory/ERC3643/interfaces/IDiamondLoupe.sol b/packages/ats/contracts/contracts/factory/ERC3643/interfaces/IDiamondLoupe.sol index d6a28a573..0deab25ae 100644 --- a/packages/ats/contracts/contracts/factory/ERC3643/interfaces/IDiamondLoupe.sol +++ b/packages/ats/contracts/contracts/factory/ERC3643/interfaces/IDiamondLoupe.sol @@ -1,17 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.17; -// A loupe is a small magnifying glass used to look at resolverProxys. -// These functions look at resolverProxys -/// #### Structs -/// ``` -/// struct Facet { -/// bytes32 facetId; -/// address facetAddress; -/// bytes4[] selectors; -/// } -///``` -// HACK: I think that Loupe and Cut should be only one contract. interface TRexIDiamondLoupe { struct Facet { bytes32 id; diff --git a/packages/ats/contracts/contracts/factory/ERC3643/interfaces/IFactory.sol b/packages/ats/contracts/contracts/factory/ERC3643/interfaces/IFactory.sol index 4488fec34..d29b68c70 100644 --- a/packages/ats/contracts/contracts/factory/ERC3643/interfaces/IFactory.sol +++ b/packages/ats/contracts/contracts/factory/ERC3643/interfaces/IFactory.sol @@ -19,7 +19,6 @@ interface TRexIFactory { uint256 version; } - // TODO: Separete common data in new struct struct SecurityData { bool arePartitionsProtected; bool isMultiPartition; diff --git a/packages/ats/contracts/contracts/interfaces/factory/IFactory.sol b/packages/ats/contracts/contracts/interfaces/factory/IFactory.sol index bf2b0ed1f..731f3da20 100644 --- a/packages/ats/contracts/contracts/interfaces/factory/IFactory.sol +++ b/packages/ats/contracts/contracts/interfaces/factory/IFactory.sol @@ -24,7 +24,6 @@ interface IFactory { uint256 version; } - // TODO: Separete common data in new struct struct SecurityData { bool arePartitionsProtected; bool isMultiPartition; diff --git a/packages/ats/contracts/contracts/interfaces/resolver/resolverProxy/IDiamondLoupe.sol b/packages/ats/contracts/contracts/interfaces/resolver/resolverProxy/IDiamondLoupe.sol index 53b015482..b9ced40eb 100644 --- a/packages/ats/contracts/contracts/interfaces/resolver/resolverProxy/IDiamondLoupe.sol +++ b/packages/ats/contracts/contracts/interfaces/resolver/resolverProxy/IDiamondLoupe.sol @@ -3,17 +3,6 @@ pragma solidity >=0.8.0 <0.9.0; import { IStaticFunctionSelectors } from "./IStaticFunctionSelectors.sol"; -// A loupe is a small magnifying glass used to look at resolverProxys. -// These functions look at resolverProxys -/// #### Structs -/// ``` -/// struct Facet { -/// bytes32 facetId; -/// address facetAddress; -/// bytes4[] selectors; -/// } -///``` -// HACK: I think that Loupe and Cut should be only one contract. interface IDiamondLoupe is IStaticFunctionSelectors { struct Facet { bytes32 id; diff --git a/packages/ats/contracts/contracts/layer_0/ERC1400/ERC1410/ERC1410BasicStorageWrapper.sol b/packages/ats/contracts/contracts/layer_0/ERC1400/ERC1410/ERC1410BasicStorageWrapper.sol index 95b337063..29ebd4c4b 100644 --- a/packages/ats/contracts/contracts/layer_0/ERC1400/ERC1410/ERC1410BasicStorageWrapper.sol +++ b/packages/ats/contracts/contracts/layer_0/ERC1400/ERC1410/ERC1410BasicStorageWrapper.sol @@ -55,7 +55,7 @@ abstract contract ERC1410BasicStorageWrapper is IERC1410StorageWrapper, ERC20Sto _afterTokenTransfer(_partition, _from, _basicTransferInfo.to, _basicTransferInfo.value); - return bytes32(0); + return _partition; } function _beforeTokenTransfer(bytes32 partition, address from, address to, uint256 amount) internal virtual; diff --git a/packages/ats/contracts/contracts/layer_0/ERC1400/ERC1410/ERC1410BasicStorageWrapperRead.sol b/packages/ats/contracts/contracts/layer_0/ERC1400/ERC1410/ERC1410BasicStorageWrapperRead.sol index 6370f87eb..798e2006f 100644 --- a/packages/ats/contracts/contracts/layer_0/ERC1400/ERC1410/ERC1410BasicStorageWrapperRead.sol +++ b/packages/ats/contracts/contracts/layer_0/ERC1400/ERC1410/ERC1410BasicStorageWrapperRead.sol @@ -240,10 +240,6 @@ abstract contract ERC1410BasicStorageWrapperRead is IERC1410StorageWrapper, Lock } } - function _checkValidAddress(address account) internal pure { - if (account == address(0)) revert ZeroAddressNotAllowed(); - } - function _adjustTotalBalanceFor(ERC1410BasicStorage storage basicStorage, uint256 abaf, address account) private { uint256 factor = _calculateFactorByAbafAndTokenHolder(abaf, account); basicStorage.balances[account] *= factor; diff --git a/packages/ats/contracts/contracts/layer_0/ERC1400/ERC1410/ERC1410ProtectedPartitionsStorageWrapper.sol b/packages/ats/contracts/contracts/layer_0/ERC1400/ERC1410/ERC1410ProtectedPartitionsStorageWrapper.sol index 10711d6c2..1146ff909 100644 --- a/packages/ats/contracts/contracts/layer_0/ERC1400/ERC1410/ERC1410ProtectedPartitionsStorageWrapper.sol +++ b/packages/ats/contracts/contracts/layer_0/ERC1400/ERC1410/ERC1410ProtectedPartitionsStorageWrapper.sol @@ -4,6 +4,9 @@ pragma solidity >=0.8.0 <0.9.0; import { BasicTransferInfo } from "../../../layer_1/interfaces/ERC1400/IERC1410.sol"; import { ERC1644StorageWrapper } from "../ERC1644/ERC1644StorageWrapper.sol"; import { checkNounceAndDeadline } from "../../../layer_1/protectedPartitions/signatureVerification.sol"; +import { + IProtectedPartitionsStorageWrapper +} from "../../../layer_1/interfaces/protectedPartitions/IProtectedPartitionsStorageWrapper.sol"; abstract contract ERC1410ProtectedPartitionsStorageWrapper is ERC1644StorageWrapper { function _protectedTransferFromByPartition( @@ -11,31 +14,39 @@ abstract contract ERC1410ProtectedPartitionsStorageWrapper is ERC1644StorageWrap address _from, address _to, uint256 _amount, - uint256 _deadline, - uint256 _nounce, - bytes calldata _signature - ) internal { - checkNounceAndDeadline(_nounce, _from, _getNounceFor(_from), _deadline, _blockTimestamp()); + IProtectedPartitionsStorageWrapper.ProtectionData calldata _protectionData + ) internal returns (bytes32) { + checkNounceAndDeadline( + _protectionData.nounce, + _from, + _getNounceFor(_from), + _protectionData.deadline, + _blockTimestamp() + ); - _checkTransferSignature(_partition, _from, _to, _amount, _deadline, _nounce, _signature); + _checkTransferSignature(_partition, _from, _to, _amount, _protectionData); - _setNounce(_nounce, _from); + _setNounce(_protectionData.nounce, _from); - _transferByPartition(_from, BasicTransferInfo(_to, _amount), _partition, "", _msgSender(), ""); + return _transferByPartition(_from, BasicTransferInfo(_to, _amount), _partition, "", _msgSender(), ""); } function _protectedRedeemFromByPartition( bytes32 _partition, address _from, uint256 _amount, - uint256 _deadline, - uint256 _nounce, - bytes calldata _signature + IProtectedPartitionsStorageWrapper.ProtectionData calldata _protectionData ) internal { - checkNounceAndDeadline(_nounce, _from, _getNounceFor(_from), _deadline, _blockTimestamp()); - - _checkRedeemSignature(_partition, _from, _amount, _deadline, _nounce, _signature); - _setNounce(_nounce, _from); + checkNounceAndDeadline( + _protectionData.nounce, + _from, + _getNounceFor(_from), + _protectionData.deadline, + _blockTimestamp() + ); + + _checkRedeemSignature(_partition, _from, _amount, _protectionData); + _setNounce(_protectionData.nounce, _from); _redeemByPartition(_partition, _from, _msgSender(), _amount, "", ""); } diff --git a/packages/ats/contracts/contracts/layer_0/ERC1400/ERC1594/ERC1594StorageWrapper.sol b/packages/ats/contracts/contracts/layer_0/ERC1400/ERC1594/ERC1594StorageWrapper.sol index 4ee73bca5..d8fb88a20 100644 --- a/packages/ats/contracts/contracts/layer_0/ERC1400/ERC1594/ERC1594StorageWrapper.sol +++ b/packages/ats/contracts/contracts/layer_0/ERC1400/ERC1594/ERC1594StorageWrapper.sol @@ -61,7 +61,6 @@ abstract contract ERC1594StorageWrapper is IERC1594StorageWrapper, CapStorageWra ds.initialized = true; } - // TODO: In this case are able to perform that operation another role? function _issue(address _tokenHolder, uint256 _value, bytes memory _data) internal { // Add a function to validate the `_data` parameter _mint(_tokenHolder, _value); diff --git a/packages/ats/contracts/contracts/layer_0/ERC1400/ERC20Votes/ERC20VotesStorageWrapper.sol b/packages/ats/contracts/contracts/layer_0/ERC1400/ERC20Votes/ERC20VotesStorageWrapper.sol index b8812d5a8..988428383 100644 --- a/packages/ats/contracts/contracts/layer_0/ERC1400/ERC20Votes/ERC20VotesStorageWrapper.sol +++ b/packages/ats/contracts/contracts/layer_0/ERC1400/ERC20Votes/ERC20VotesStorageWrapper.sol @@ -71,14 +71,14 @@ abstract contract ERC20VotesStorageWrapper is ERC1594StorageWrapper { } function _delegate(address delegator, address delegatee) internal virtual { - _triggerScheduledCrossOrderedTasks(0); - - _takeAbafCheckpoint(); - address currentDelegate = _delegates(delegator); if (currentDelegate == delegatee) return; + _triggerScheduledCrossOrderedTasks(0); + + _takeAbafCheckpoint(); + uint256 delegatorBalance = _balanceOfAdjustedAt(delegator, _blockTimestamp()) + _getLockedAmountForAdjustedAt(delegator, _blockTimestamp()) + _getHeldAmountForAdjusted(delegator) + diff --git a/packages/ats/contracts/contracts/layer_0/clearing/ClearingStorageWrapper2.sol b/packages/ats/contracts/contracts/layer_0/clearing/ClearingStorageWrapper2.sol index 257d2fda6..99ac6520a 100644 --- a/packages/ats/contracts/contracts/layer_0/clearing/ClearingStorageWrapper2.sol +++ b/packages/ats/contracts/contracts/layer_0/clearing/ClearingStorageWrapper2.sol @@ -246,7 +246,7 @@ abstract contract ClearingStorageWrapper2 is IClearingStorageWrapper, HoldStorag function _approveClearingOperationByPartition( IClearing.ClearingOperationIdentifier calldata _clearingOperationIdentifier - ) internal returns (bool success_, bytes memory operationData_) { + ) internal returns (bool success_, bytes memory operationData_, bytes32 partition_) { return _handleClearingOperationByPartition( _clearingOperationIdentifier, @@ -257,7 +257,7 @@ abstract contract ClearingStorageWrapper2 is IClearingStorageWrapper, HoldStorag function _cancelClearingOperationByPartition( IClearing.ClearingOperationIdentifier calldata _clearingOperationIdentifier ) internal returns (bool success_) { - (success_, ) = _handleClearingOperationByPartition( + (success_, , ) = _handleClearingOperationByPartition( _clearingOperationIdentifier, IClearingActions.ClearingActionType.Cancel ); @@ -266,7 +266,7 @@ abstract contract ClearingStorageWrapper2 is IClearingStorageWrapper, HoldStorag function _reclaimClearingOperationByPartition( IClearing.ClearingOperationIdentifier calldata _clearingOperationIdentifier ) internal returns (bool success_) { - (success_, ) = _handleClearingOperationByPartition( + (success_, , ) = _handleClearingOperationByPartition( _clearingOperationIdentifier, IClearingActions.ClearingActionType.Reclaim ); @@ -275,14 +275,14 @@ abstract contract ClearingStorageWrapper2 is IClearingStorageWrapper, HoldStorag function _handleClearingOperationByPartition( IClearing.ClearingOperationIdentifier calldata _clearingOperationIdentifier, IClearingActions.ClearingActionType operationType - ) internal returns (bool success_, bytes memory operationData_) { + ) internal returns (bool success_, bytes memory operationData_, bytes32 partition_) { _beforeClearingOperation( _clearingOperationIdentifier, _getClearingBasicInfo(_clearingOperationIdentifier).destination ); uint256 amount; ThirdPartyType operatorType; - (success_, amount, operatorType, operationData_) = _operateClearingAction( + (success_, amount, operatorType, operationData_, partition_) = _operateClearingAction( _clearingOperationIdentifier, operationType ); @@ -292,15 +292,24 @@ abstract contract ClearingStorageWrapper2 is IClearingStorageWrapper, HoldStorag function _operateClearingAction( IClearing.ClearingOperationIdentifier calldata _clearingOperationIdentifier, IClearingActions.ClearingActionType _operation - ) internal returns (bool success_, uint256 amount_, ThirdPartyType operatorType_, bytes memory operationData_) { + ) + internal + returns ( + bool success_, + uint256 amount_, + ThirdPartyType operatorType_, + bytes memory operationData_, + bytes32 partition_ + ) + { if (_clearingOperationIdentifier.clearingOperationType == IClearing.ClearingOperationType.Transfer) { - (success_, amount_, operatorType_) = _clearingTransferExecution( + (success_, amount_, operatorType_, partition_) = _clearingTransferExecution( _clearingOperationIdentifier.partition, _clearingOperationIdentifier.tokenHolder, _clearingOperationIdentifier.clearingId, _operation ); - return (success_, amount_, operatorType_, operationData_); + return (success_, amount_, operatorType_, operationData_, partition_); } if (_clearingOperationIdentifier.clearingOperationType == IClearing.ClearingOperationType.Redeem) { @@ -310,16 +319,17 @@ abstract contract ClearingStorageWrapper2 is IClearingStorageWrapper, HoldStorag _clearingOperationIdentifier.clearingId, _operation ); - return (success_, amount_, operatorType_, operationData_); + return (success_, amount_, operatorType_, operationData_, bytes32(0)); } - return - _clearingHoldCreationExecution( - _clearingOperationIdentifier.partition, - _clearingOperationIdentifier.tokenHolder, - _clearingOperationIdentifier.clearingId, - _operation - ); + (success_, amount_, operatorType_, operationData_) = _clearingHoldCreationExecution( + _clearingOperationIdentifier.partition, + _clearingOperationIdentifier.tokenHolder, + _clearingOperationIdentifier.clearingId, + _operation + ); + + return (success_, amount_, operatorType_, operationData_, bytes32(0)); } function _transferClearingBalance(bytes32 _partition, address _to, uint256 _amount) internal { @@ -622,7 +632,7 @@ abstract contract ClearingStorageWrapper2 is IClearingStorageWrapper, HoldStorag address _tokenHolder, uint256 _clearingId, IClearingActions.ClearingActionType _operation - ) private returns (bool success_, uint256 amount_, ThirdPartyType operatorType_) { + ) private returns (bool success_, uint256 amount_, ThirdPartyType operatorType_, bytes32 partition_) { IClearing.ClearingTransferData memory clearingTransferData = _getClearingTransferForByPartition( _partition, _tokenHolder, @@ -636,6 +646,8 @@ abstract contract ClearingStorageWrapper2 is IClearingStorageWrapper, HoldStorag _checkCompliance(_tokenHolder, clearingTransferData.destination, false); destination = clearingTransferData.destination; + + partition_ = _partition; } _transferClearingBalance(_partition, destination, clearingTransferData.amount); diff --git a/packages/ats/contracts/contracts/layer_0/core/accessControl/AccessControlStorageWrapper.sol b/packages/ats/contracts/contracts/layer_0/core/accessControl/AccessControlStorageWrapper.sol index e56a220cd..1c4b2f8e9 100644 --- a/packages/ats/contracts/contracts/layer_0/core/accessControl/AccessControlStorageWrapper.sol +++ b/packages/ats/contracts/contracts/layer_0/core/accessControl/AccessControlStorageWrapper.sol @@ -16,7 +16,6 @@ abstract contract AccessControlStorageWrapper is LocalContext, BusinessLogicResolverWrapper { - // TODO: Check if it's possible to use only one dependency of AddressSet and Bytes32Set using LibCommon for EnumerableSet.AddressSet; using LibCommon for EnumerableSet.Bytes32Set; using EnumerableSet for EnumerableSet.AddressSet; diff --git a/packages/ats/contracts/contracts/layer_0/core/externalLists/ExternalListManagementStorageWrapper.sol b/packages/ats/contracts/contracts/layer_0/core/externalLists/ExternalListManagementStorageWrapper.sol index 9c7b5a34a..25d290549 100644 --- a/packages/ats/contracts/contracts/layer_0/core/externalLists/ExternalListManagementStorageWrapper.sol +++ b/packages/ats/contracts/contracts/layer_0/core/externalLists/ExternalListManagementStorageWrapper.sol @@ -14,6 +14,8 @@ abstract contract ExternalListManagementStorageWrapper is SsiManagementStorageWr EnumerableSet.AddressSet list; } + error ZeroAddressNotAllowed(); + function _updateExternalLists( bytes32 _position, address[] calldata _lists, @@ -21,6 +23,7 @@ abstract contract ExternalListManagementStorageWrapper is SsiManagementStorageWr ) internal returns (bool success_) { uint256 length = _lists.length; for (uint256 index; index < length; ) { + _checkValidAddress(_lists[index]); if (_actives[index]) { if (!_isExternalList(_position, _lists[index])) { _addExternalList(_position, _lists[index]); @@ -64,6 +67,10 @@ abstract contract ExternalListManagementStorageWrapper is SsiManagementStorageWr members_ = _externalListStorage(_position).list.getFromSet(_pageIndex, _pageLength); } + function _checkValidAddress(address account) internal pure { + if (account == address(0)) revert ZeroAddressNotAllowed(); + } + function _externalListStorage( bytes32 _position ) internal pure returns (ExternalListDataStorage storage externalList_) { diff --git a/packages/ats/contracts/contracts/layer_0/core/protectedPartitions/ProtectedPartitionsStorageWrapper.sol b/packages/ats/contracts/contracts/layer_0/core/protectedPartitions/ProtectedPartitionsStorageWrapper.sol index 9de4c0e19..70738f193 100644 --- a/packages/ats/contracts/contracts/layer_0/core/protectedPartitions/ProtectedPartitionsStorageWrapper.sol +++ b/packages/ats/contracts/contracts/layer_0/core/protectedPartitions/ProtectedPartitionsStorageWrapper.sol @@ -65,12 +65,9 @@ abstract contract ProtectedPartitionsStorageWrapper is IProtectedPartitionsStora address _from, address _to, uint256 _amount, - uint256 _deadline, - uint256 _nounce, - bytes calldata _signature + IProtectedPartitionsStorageWrapper.ProtectionData calldata _protectionData ) internal view { - if (!_isTransferSignatureValid(_partition, _from, _to, _amount, _deadline, _nounce, _signature)) - revert WrongSignature(); + if (!_isTransferSignatureValid(_partition, _from, _to, _amount, _protectionData)) revert WrongSignature(); } function _isTransferSignatureValid( @@ -78,16 +75,21 @@ abstract contract ProtectedPartitionsStorageWrapper is IProtectedPartitionsStora address _from, address _to, uint256 _amount, - uint256 _deadline, - uint256 _nounce, - bytes calldata _signature + IProtectedPartitionsStorageWrapper.ProtectionData calldata _protectionData ) internal view returns (bool) { - bytes32 functionHash = getMessageHashTransfer(_partition, _from, _to, _amount, _deadline, _nounce); + bytes32 functionHash = getMessageHashTransfer( + _partition, + _from, + _to, + _amount, + _protectionData.deadline, + _protectionData.nounce + ); return verify( _from, functionHash, - _signature, + _protectionData.signature, _protectedPartitionsStorage().contractName, _protectedPartitionsStorage().contractVersion, _blockChainid(), @@ -99,28 +101,29 @@ abstract contract ProtectedPartitionsStorageWrapper is IProtectedPartitionsStora bytes32 _partition, address _from, uint256 _amount, - uint256 _deadline, - uint256 _nounce, - bytes calldata _signature + IProtectedPartitionsStorageWrapper.ProtectionData calldata _protectionData ) internal view { - if (!_isRedeemSignatureValid(_partition, _from, _amount, _deadline, _nounce, _signature)) - revert WrongSignature(); + if (!_isRedeemSignatureValid(_partition, _from, _amount, _protectionData)) revert WrongSignature(); } function _isRedeemSignatureValid( bytes32 _partition, address _from, uint256 _amount, - uint256 _deadline, - uint256 _nounce, - bytes calldata _signature + IProtectedPartitionsStorageWrapper.ProtectionData calldata _protectionData ) internal view returns (bool) { - bytes32 functionHash = getMessageHashRedeem(_partition, _from, _amount, _deadline, _nounce); + bytes32 functionHash = getMessageHashRedeem( + _partition, + _from, + _amount, + _protectionData.deadline, + _protectionData.nounce + ); return verify( _from, functionHash, - _signature, + _protectionData.signature, _protectedPartitionsStorage().contractName, _protectedPartitionsStorage().contractVersion, _blockChainid(), diff --git a/packages/ats/contracts/contracts/layer_0/corporateActions/CorporateActionsStorageWrapper.sol b/packages/ats/contracts/contracts/layer_0/corporateActions/CorporateActionsStorageWrapper.sol index 1576c9d7e..4732dc6f9 100644 --- a/packages/ats/contracts/contracts/layer_0/corporateActions/CorporateActionsStorageWrapper.sol +++ b/packages/ats/contracts/contracts/layer_0/corporateActions/CorporateActionsStorageWrapper.sol @@ -34,8 +34,14 @@ abstract contract CorporateActionsStorageWrapper is ClearingStorageWrapper1 { bytes memory _data ) internal returns (bool success_, bytes32 corporateActionId_, uint256 corporateActionIndexByType_) { CorporateActionDataStorage storage corporateActions_ = _corporateActionsStorage(); + + bytes32 contentHash = keccak256(abi.encode(_actionType, _data)); + if (corporateActions_.actionsContentHashes[contentHash]) { + return (false, bytes32(0), 0); + } + corporateActions_.actionsContentHashes[contentHash] = true; + corporateActionId_ = bytes32(corporateActions_.actions.length() + 1); - // TODO: Review when it can return false. success_ = corporateActions_.actions.add(corporateActionId_) && corporateActions_.actionsByType[_actionType].add(corporateActionId_); @@ -124,6 +130,10 @@ abstract contract CorporateActionsStorageWrapper is ClearingStorageWrapper1 { return value; } + function _actionContentHashExists(bytes32 _contentHash) internal view returns (bool) { + return _corporateActionsStorage().actionsContentHashes[_contentHash]; + } + function _corporateActionsStorage() internal pure returns (CorporateActionDataStorage storage corporateActions_) { bytes32 position = _CORPORATE_ACTION_STORAGE_POSITION; // solhint-disable-next-line no-inline-assembly diff --git a/packages/ats/contracts/contracts/layer_0/equity/EquityStorageWrapper.sol b/packages/ats/contracts/contracts/layer_0/equity/EquityStorageWrapper.sol index 5133cb7f6..0ce6b3ca5 100644 --- a/packages/ats/contracts/contracts/layer_0/equity/EquityStorageWrapper.sol +++ b/packages/ats/contracts/contracts/layer_0/equity/EquityStorageWrapper.sol @@ -294,7 +294,7 @@ abstract contract EquityStorageWrapper is IEquityStorageWrapper, BondStorageWrap return _getTotalTokenHolders(); } - function _getScheduledBalanceAdjusment( + function _getScheduledBalanceAdjustment( uint256 _balanceAdjustmentID ) internal view returns (IEquity.ScheduledBalanceAdjustment memory balanceAdjustment_) { bytes32 actionId = _corporateActionsStorage().actionsByType[BALANCE_ADJUSTMENT_CORPORATE_ACTION_TYPE].at( diff --git a/packages/ats/contracts/contracts/layer_0/hold/HoldStorageWrapper2.sol b/packages/ats/contracts/contracts/layer_0/hold/HoldStorageWrapper2.sol index b0a727ee7..80e45c115 100644 --- a/packages/ats/contracts/contracts/layer_0/hold/HoldStorageWrapper2.sol +++ b/packages/ats/contracts/contracts/layer_0/hold/HoldStorageWrapper2.sol @@ -90,10 +90,11 @@ abstract contract HoldStorageWrapper2 is ERC1410ProtectedPartitionsStorageWrappe HoldIdentifier calldata _holdIdentifier, address _to, uint256 _amount - ) internal returns (bool success_) { + ) internal returns (bool success_, bytes32 partition_) { _beforeExecuteHold(_holdIdentifier, _to); success_ = _operateHoldByPartition(_holdIdentifier, _to, _amount, OperationType.Execute); + partition_ = _holdIdentifier.partition; HoldData memory holdData = _getHold(_holdIdentifier); @@ -287,12 +288,10 @@ abstract contract HoldStorageWrapper2 is ERC1410ProtectedPartitionsStorageWrappe } function _beforeReleaseHold(HoldIdentifier calldata _holdIdentifier) internal { - _adjustHoldBalances(_holdIdentifier, _holdIdentifier.tokenHolder); _beforeExecuteHold(_holdIdentifier, _holdIdentifier.tokenHolder); } function _beforeReclaimHold(HoldIdentifier calldata _holdIdentifier) internal { - _adjustHoldBalances(_holdIdentifier, _holdIdentifier.tokenHolder); _beforeExecuteHold(_holdIdentifier, _holdIdentifier.tokenHolder); } diff --git a/packages/ats/contracts/contracts/layer_0/lock/LockStorageWrapper2.sol b/packages/ats/contracts/contracts/layer_0/lock/LockStorageWrapper2.sol index a4499300d..d5fb02c51 100644 --- a/packages/ats/contracts/contracts/layer_0/lock/LockStorageWrapper2.sol +++ b/packages/ats/contracts/contracts/layer_0/lock/LockStorageWrapper2.sol @@ -65,7 +65,6 @@ abstract contract LockStorageWrapper2 is AdjustBalancesStorageWrapper2 { } success_ = true; - _removeLabafLock(_partition, _tokenHolder, _lockId); } function _updateTotalLock(bytes32 _partition, address _tokenHolder) internal returns (uint256 abaf_) { diff --git a/packages/ats/contracts/contracts/layer_0/transferAndLock/TransferAndLockStorageWrapper.sol b/packages/ats/contracts/contracts/layer_0/transferAndLock/TransferAndLockStorageWrapper.sol index 8db597055..ab24f79d8 100644 --- a/packages/ats/contracts/contracts/layer_0/transferAndLock/TransferAndLockStorageWrapper.sol +++ b/packages/ats/contracts/contracts/layer_0/transferAndLock/TransferAndLockStorageWrapper.sol @@ -11,26 +11,27 @@ import { } from "../../layer_3/transferAndLock/signatureVerification.sol"; import { BasicTransferInfo } from "../../layer_1/interfaces/ERC1400/IERC1410.sol"; import { SecurityStorageWrapper } from "../security/SecurityStorageWrapper.sol"; +import { + IProtectedPartitionsStorageWrapper +} from "../../layer_1/interfaces/protectedPartitions/IProtectedPartitionsStorageWrapper.sol"; abstract contract TransferAndLockStorageWrapper is ITransferAndLockStorageWrapper, SecurityStorageWrapper { function _protectedTransferAndLockByPartition( bytes32 _partition, ITransferAndLock.TransferAndLockStruct calldata _transferAndLock, - uint256 _deadline, - uint256 _nounce, - bytes calldata _signature + IProtectedPartitionsStorageWrapper.ProtectionData calldata _protectionData ) internal returns (bool success_, uint256 lockId_) { checkNounceAndDeadline( - _nounce, + _protectionData.nounce, _transferAndLock.from, _getNounceFor(_transferAndLock.from), - _deadline, + _protectionData.deadline, _blockTimestamp() ); - _checkTransferAndLockByPartitionSignature(_partition, _transferAndLock, _deadline, _nounce, _signature); + _checkTransferAndLockByPartitionSignature(_partition, _transferAndLock, _protectionData); - _setNounce(_nounce, _transferAndLock.from); + _setNounce(_protectionData.nounce, _transferAndLock.from); _transferByPartition( _msgSender(), @@ -60,21 +61,19 @@ abstract contract TransferAndLockStorageWrapper is ITransferAndLockStorageWrappe function _protectedTransferAndLock( ITransferAndLock.TransferAndLockStruct calldata _transferAndLock, - uint256 _deadline, - uint256 _nounce, - bytes calldata _signature + IProtectedPartitionsStorageWrapper.ProtectionData calldata _protectionData ) internal returns (bool success_, uint256 lockId_) { checkNounceAndDeadline( - _nounce, + _protectionData.nounce, _transferAndLock.from, _getNounceFor(_transferAndLock.from), - _deadline, + _protectionData.deadline, _blockTimestamp() ); - _checkTransferAndLockSignature(_transferAndLock, _deadline, _nounce, _signature); + _checkTransferAndLockSignature(_transferAndLock, _protectionData); - _setNounce(_nounce, _transferAndLock.from); + _setNounce(_protectionData.nounce, _transferAndLock.from); _transferByPartition( _msgSender(), @@ -105,20 +104,16 @@ abstract contract TransferAndLockStorageWrapper is ITransferAndLockStorageWrappe function _checkTransferAndLockByPartitionSignature( bytes32 _partition, ITransferAndLock.TransferAndLockStruct calldata _transferAndLock, - uint256 _deadline, - uint256 _nounce, - bytes calldata _signature + IProtectedPartitionsStorageWrapper.ProtectionData calldata _protectionData ) internal view { - if (!_isTransferAndLockByPartitionSignatureValid(_partition, _transferAndLock, _deadline, _nounce, _signature)) + if (!_isTransferAndLockByPartitionSignatureValid(_partition, _transferAndLock, _protectionData)) revert WrongSignature(); } function _isTransferAndLockByPartitionSignatureValid( bytes32 _partition, ITransferAndLock.TransferAndLockStruct calldata _transferAndLock, - uint256 _deadline, - uint256 _nounce, - bytes calldata _signature + IProtectedPartitionsStorageWrapper.ProtectionData calldata _protectionData ) internal view returns (bool) { bytes32 functionHash = getMessageHashTransferAndLockByPartition( _partition, @@ -127,14 +122,14 @@ abstract contract TransferAndLockStorageWrapper is ITransferAndLockStorageWrappe _transferAndLock.amount, _transferAndLock.data, _transferAndLock.expirationTimestamp, - _deadline, - _nounce + _protectionData.deadline, + _protectionData.nounce ); return verify( _transferAndLock.from, functionHash, - _signature, + _protectionData.signature, _protectedPartitionsStorage().contractName, _protectedPartitionsStorage().contractVersion, _blockChainid(), @@ -144,19 +139,14 @@ abstract contract TransferAndLockStorageWrapper is ITransferAndLockStorageWrappe function _checkTransferAndLockSignature( ITransferAndLock.TransferAndLockStruct calldata _transferAndLock, - uint256 _deadline, - uint256 _nounce, - bytes calldata _signature + IProtectedPartitionsStorageWrapper.ProtectionData calldata _protectionData ) internal view { - if (!_isTransferAndLockSignatureValid(_transferAndLock, _deadline, _nounce, _signature)) - revert WrongSignature(); + if (!_isTransferAndLockSignatureValid(_transferAndLock, _protectionData)) revert WrongSignature(); } function _isTransferAndLockSignatureValid( ITransferAndLock.TransferAndLockStruct calldata _transferAndLock, - uint256 _deadline, - uint256 _nounce, - bytes calldata _signature + IProtectedPartitionsStorageWrapper.ProtectionData calldata _protectionData ) internal view returns (bool) { bytes32 functionHash = getMessageHashTransferAndLock( _transferAndLock.from, @@ -164,14 +154,14 @@ abstract contract TransferAndLockStorageWrapper is ITransferAndLockStorageWrappe _transferAndLock.amount, _transferAndLock.data, _transferAndLock.expirationTimestamp, - _deadline, - _nounce + _protectionData.deadline, + _protectionData.nounce ); return verify( _transferAndLock.from, functionHash, - _signature, + _protectionData.signature, _protectedPartitionsStorage().contractName, _protectedPartitionsStorage().contractVersion, _blockChainid(), diff --git a/packages/ats/contracts/contracts/layer_1/ERC1400/ERC1410/ERC1410Management.sol b/packages/ats/contracts/contracts/layer_1/ERC1400/ERC1410/ERC1410Management.sol index 442506f2d..1605014b6 100644 --- a/packages/ats/contracts/contracts/layer_1/ERC1400/ERC1410/ERC1410Management.sol +++ b/packages/ats/contracts/contracts/layer_1/ERC1400/ERC1410/ERC1410Management.sol @@ -6,6 +6,9 @@ import { BasicTransferInfo, OperatorTransferData } from "../../interfaces/ERC140 import { IERC1410Management } from "../../interfaces/ERC1400/IERC1410Management.sol"; import { Common } from "../../common/Common.sol"; import { IssueData } from "../../../layer_1/interfaces/ERC1400/IERC1410.sol"; +import { + IProtectedPartitionsStorageWrapper +} from "../../interfaces/protectedPartitions/IProtectedPartitionsStorageWrapper.sol"; abstract contract ERC1410Management is IERC1410Management, Common { // solhint-disable-next-line func-name-mixedcase @@ -23,14 +26,22 @@ abstract contract ERC1410Management is IERC1410Management, Common { uint256 _value, bytes calldata _data, bytes calldata _operatorData - ) external override onlyUnpaused onlyDefaultPartitionWithSinglePartition(_partition) onlyControllable { + ) + external + override + onlyUnpaused + onlyDefaultPartitionWithSinglePartition(_partition) + onlyControllable + returns (bytes32) + { { bytes32[] memory roles = new bytes32[](2); roles[0] = _CONTROLLER_ROLE; roles[1] = _AGENT_ROLE; _checkAnyRole(roles, _msgSender()); } - _transferByPartition(_from, BasicTransferInfo(_to, _value), _partition, _data, _msgSender(), _operatorData); + return + _transferByPartition(_from, BasicTransferInfo(_to, _value), _partition, _data, _msgSender(), _operatorData); } function controllerRedeemByPartition( @@ -95,26 +106,23 @@ abstract contract ERC1410Management is IERC1410Management, Common { address _from, address _to, uint256 _amount, - uint256 _deadline, - uint256 _nounce, - bytes calldata _signature + IProtectedPartitionsStorageWrapper.ProtectionData calldata _protectionData ) external override onlyRole(_protectedPartitionsRole(_partition)) onlyProtectedPartitions onlyCanTransferFromByPartition(_from, _to, _partition, _amount, "", "") + returns (bytes32) { - _protectedTransferFromByPartition(_partition, _from, _to, _amount, _deadline, _nounce, _signature); + return _protectedTransferFromByPartition(_partition, _from, _to, _amount, _protectionData); } function protectedRedeemFromByPartition( bytes32 _partition, address _from, uint256 _amount, - uint256 _deadline, - uint256 _nounce, - bytes calldata _signature + IProtectedPartitionsStorageWrapper.ProtectionData calldata _protectionData ) external override @@ -122,6 +130,6 @@ abstract contract ERC1410Management is IERC1410Management, Common { onlyProtectedPartitions onlyCanRedeemFromByPartition(_from, _partition, _amount, "", "") { - _protectedRedeemFromByPartition(_partition, _from, _amount, _deadline, _nounce, _signature); + _protectedRedeemFromByPartition(_partition, _from, _amount, _protectionData); } } diff --git a/packages/ats/contracts/contracts/layer_1/ERC1400/ERC1410/ERC1410TokenHolder.sol b/packages/ats/contracts/contracts/layer_1/ERC1400/ERC1410/ERC1410TokenHolder.sol index 905b8102c..6b7a5657d 100644 --- a/packages/ats/contracts/contracts/layer_1/ERC1400/ERC1410/ERC1410TokenHolder.sol +++ b/packages/ats/contracts/contracts/layer_1/ERC1400/ERC1410/ERC1410TokenHolder.sol @@ -31,14 +31,6 @@ abstract contract ERC1410TokenHolder is IERC1410TokenHolder, Common { ) returns (bytes32) { - // Add a function to verify the `_data` parameter - // TODO: Need to create the bytes division of the `_partition` so it can be easily findout in which receiver's - // partition token will transfered. For current implementation we are assuming that the receiver's partition - // will be same as sender's as well as it also pass the `_validPartition()` check. In this particular case we - // are also assuming that reciever has the some tokens of the same partition as well (To avoid the array index - // out of bound error). - // Note- There is no operator used for the execution of this call so `_operator` value in - // in event is address(0) same for the `_operatorData` return _transferByPartition(msg.sender, _basicTransferInfo, _partition, _data, address(0), ""); } @@ -53,7 +45,6 @@ abstract contract ERC1410TokenHolder is IERC1410TokenHolder, Common { onlyUnProtectedPartitionsOrWildCardRole onlyCanRedeemFromByPartition(_msgSender(), _partition, _value, _data, "") { - // Add the function to validate the `_data` parameter _redeemByPartition(_partition, _msgSender(), address(0), _value, _data, ""); } diff --git a/packages/ats/contracts/contracts/layer_1/clearing/ClearingActions.sol b/packages/ats/contracts/contracts/layer_1/clearing/ClearingActions.sol index 192e635ab..971c42d78 100644 --- a/packages/ats/contracts/contracts/layer_1/clearing/ClearingActions.sol +++ b/packages/ats/contracts/contracts/layer_1/clearing/ClearingActions.sol @@ -35,10 +35,10 @@ abstract contract ClearingActions is IClearingActions, Common { onlyWithValidClearingId(_clearingOperationIdentifier) onlyClearingActivated validateExpirationTimestamp(_clearingOperationIdentifier, false) - returns (bool success_) + returns (bool success_, bytes32 partition_) { bytes memory operationData; - (success_, operationData) = _approveClearingOperationByPartition(_clearingOperationIdentifier); + (success_, operationData, partition_) = _approveClearingOperationByPartition(_clearingOperationIdentifier); emit ClearingOperationApproved( _msgSender(), diff --git a/packages/ats/contracts/contracts/layer_1/controlList/ControlList.sol b/packages/ats/contracts/contracts/layer_1/controlList/ControlList.sol index 85ba5578d..8cce204d4 100644 --- a/packages/ats/contracts/contracts/layer_1/controlList/ControlList.sol +++ b/packages/ats/contracts/contracts/layer_1/controlList/ControlList.sol @@ -6,7 +6,6 @@ import { Common } from "../common/Common.sol"; import { _CONTROL_LIST_ROLE } from "../constants/roles.sol"; abstract contract ControlList is IControlList, Common { - // TODO: UNPAUSED // solhint-disable-next-line func-name-mixedcase function initialize_ControlList( bool _isWhiteList diff --git a/packages/ats/contracts/contracts/layer_1/corporateActions/CorporateActions.sol b/packages/ats/contracts/contracts/layer_1/corporateActions/CorporateActions.sol index 82b2c44ca..79de3132f 100644 --- a/packages/ats/contracts/contracts/layer_1/corporateActions/CorporateActions.sol +++ b/packages/ats/contracts/contracts/layer_1/corporateActions/CorporateActions.sol @@ -54,4 +54,8 @@ abstract contract CorporateActions is ICorporateActions, Common { ) external view override returns (bytes32[] memory corporateActionIds_) { corporateActionIds_ = _getCorporateActionIdsByType(_actionType, _pageIndex, _pageLength); } + + function actionContentHashExists(bytes32 _contentHash) external view returns (bool) { + return _actionContentHashExists(_contentHash); + } } diff --git a/packages/ats/contracts/contracts/layer_1/corporateActions/CorporateActionsFacet.sol b/packages/ats/contracts/contracts/layer_1/corporateActions/CorporateActionsFacet.sol index a5d906316..9f720edb4 100644 --- a/packages/ats/contracts/contracts/layer_1/corporateActions/CorporateActionsFacet.sol +++ b/packages/ats/contracts/contracts/layer_1/corporateActions/CorporateActionsFacet.sol @@ -13,13 +13,14 @@ contract CorporateActionsFacet is CorporateActions, IStaticFunctionSelectors { function getStaticFunctionSelectors() external pure override returns (bytes4[] memory staticFunctionSelectors_) { uint256 selectorIndex; - staticFunctionSelectors_ = new bytes4[](6); + staticFunctionSelectors_ = new bytes4[](7); staticFunctionSelectors_[selectorIndex++] = this.addCorporateAction.selector; staticFunctionSelectors_[selectorIndex++] = this.getCorporateAction.selector; staticFunctionSelectors_[selectorIndex++] = this.getCorporateActionCount.selector; staticFunctionSelectors_[selectorIndex++] = this.getCorporateActionIds.selector; staticFunctionSelectors_[selectorIndex++] = this.getCorporateActionCountByType.selector; staticFunctionSelectors_[selectorIndex++] = this.getCorporateActionIdsByType.selector; + staticFunctionSelectors_[selectorIndex++] = this.actionContentHashExists.selector; } function getStaticInterfaceIds() external pure override returns (bytes4[] memory staticInterfaceIds_) { diff --git a/packages/ats/contracts/contracts/layer_1/externalControlLists/ExternalControlListManagement.sol b/packages/ats/contracts/contracts/layer_1/externalControlLists/ExternalControlListManagement.sol index 803a67278..92f2b68f0 100644 --- a/packages/ats/contracts/contracts/layer_1/externalControlLists/ExternalControlListManagement.sol +++ b/packages/ats/contracts/contracts/layer_1/externalControlLists/ExternalControlListManagement.sol @@ -16,6 +16,7 @@ abstract contract ExternalControlListManagement is IExternalControlListManagemen ); uint256 length = _controlLists.length; for (uint256 index; index < length; ) { + _checkValidAddress(_controlLists[index]); _addExternalList(_CONTROL_LIST_MANAGEMENT_STORAGE_POSITION, _controlLists[index]); unchecked { ++index; @@ -44,7 +45,14 @@ abstract contract ExternalControlListManagement is IExternalControlListManagemen function addExternalControlList( address _controlList - ) external override onlyRole(_CONTROL_LIST_MANAGER_ROLE) onlyUnpaused returns (bool success_) { + ) + external + override + onlyRole(_CONTROL_LIST_MANAGER_ROLE) + onlyUnpaused + validateAddress(_controlList) + returns (bool success_) + { success_ = _addExternalList(_CONTROL_LIST_MANAGEMENT_STORAGE_POSITION, _controlList); if (!success_) { revert ListedControlList(_controlList); diff --git a/packages/ats/contracts/contracts/layer_1/externalKycLists/ExternalKycListManagement.sol b/packages/ats/contracts/contracts/layer_1/externalKycLists/ExternalKycListManagement.sol index fe74d8240..a0e78758d 100644 --- a/packages/ats/contracts/contracts/layer_1/externalKycLists/ExternalKycListManagement.sol +++ b/packages/ats/contracts/contracts/layer_1/externalKycLists/ExternalKycListManagement.sol @@ -17,6 +17,7 @@ abstract contract ExternalKycListManagement is IExternalKycListManagement, Commo ); uint256 length = _kycLists.length; for (uint256 index; index < length; ) { + _checkValidAddress(_kycLists[index]); _addExternalList(_KYC_MANAGEMENT_STORAGE_POSITION, _kycLists[index]); unchecked { ++index; @@ -45,7 +46,7 @@ abstract contract ExternalKycListManagement is IExternalKycListManagement, Commo function addExternalKycList( address _kycLists - ) external override onlyRole(_KYC_MANAGER_ROLE) onlyUnpaused returns (bool success_) { + ) external override onlyRole(_KYC_MANAGER_ROLE) onlyUnpaused validateAddress(_kycLists) returns (bool success_) { success_ = _addExternalList(_KYC_MANAGEMENT_STORAGE_POSITION, _kycLists); if (!success_) { revert ListedKycList(_kycLists); diff --git a/packages/ats/contracts/contracts/layer_1/externalPauses/ExternalPauseManagement.sol b/packages/ats/contracts/contracts/layer_1/externalPauses/ExternalPauseManagement.sol index 986a1408a..ba57016d9 100644 --- a/packages/ats/contracts/contracts/layer_1/externalPauses/ExternalPauseManagement.sol +++ b/packages/ats/contracts/contracts/layer_1/externalPauses/ExternalPauseManagement.sol @@ -16,6 +16,7 @@ abstract contract ExternalPauseManagement is IExternalPauseManagement, Common { ); uint256 length = _pauses.length; for (uint256 index; index < length; ) { + _checkValidAddress(_pauses[index]); _addExternalList(_PAUSE_MANAGEMENT_STORAGE_POSITION, _pauses[index]); unchecked { ++index; @@ -44,7 +45,7 @@ abstract contract ExternalPauseManagement is IExternalPauseManagement, Common { function addExternalPause( address _pause - ) external override onlyRole(_PAUSE_MANAGER_ROLE) onlyUnpaused returns (bool success_) { + ) external override onlyRole(_PAUSE_MANAGER_ROLE) onlyUnpaused validateAddress(_pause) returns (bool success_) { success_ = _addExternalList(_PAUSE_MANAGEMENT_STORAGE_POSITION, _pause); if (!success_) { revert ListedPause(_pause); diff --git a/packages/ats/contracts/contracts/layer_1/freeze/Freeze.sol b/packages/ats/contracts/contracts/layer_1/freeze/Freeze.sol index a7dbcfd0c..973933254a 100644 --- a/packages/ats/contracts/contracts/layer_1/freeze/Freeze.sol +++ b/packages/ats/contracts/contracts/layer_1/freeze/Freeze.sol @@ -62,7 +62,7 @@ abstract contract Freeze is IFreeze, Common { function batchSetAddressFrozen( address[] calldata _userAddresses, bool[] calldata _freeze - ) external onlyValidInputBoolArrayLength(_userAddresses, _freeze) { + ) external onlyUnpaused onlyValidInputBoolArrayLength(_userAddresses, _freeze) { { bytes32[] memory roles = new bytes32[](2); roles[0] = _FREEZE_MANAGER_ROLE; @@ -70,6 +70,7 @@ abstract contract Freeze is IFreeze, Common { _checkAnyRole(roles, _msgSender()); } for (uint256 i = 0; i < _userAddresses.length; i++) { + _checkValidAddress(_userAddresses[i]); _setAddressFrozen(_userAddresses[i], _freeze[i]); emit AddressFrozen(_userAddresses[i], _freeze[i], _msgSender()); } diff --git a/packages/ats/contracts/contracts/layer_1/hold/HoldTokenHolder.sol b/packages/ats/contracts/contracts/layer_1/hold/HoldTokenHolder.sol index f9d563376..c3a3bf3c1 100644 --- a/packages/ats/contracts/contracts/layer_1/hold/HoldTokenHolder.sol +++ b/packages/ats/contracts/contracts/layer_1/hold/HoldTokenHolder.sol @@ -75,9 +75,9 @@ abstract contract HoldTokenHolder is IHoldTokenHolder, Common { onlyIdentified(_holdIdentifier.tokenHolder, _to) onlyCompliant(address(0), _to, false) onlyWithValidHoldId(_holdIdentifier) - returns (bool success_) + returns (bool success_, bytes32 partition_) { - success_ = _executeHoldByPartition(_holdIdentifier, _to, _amount); + (success_, partition_) = _executeHoldByPartition(_holdIdentifier, _to, _amount); emit HoldByPartitionExecuted( _holdIdentifier.tokenHolder, diff --git a/packages/ats/contracts/contracts/layer_1/interfaces/ERC1400/IERC1410Management.sol b/packages/ats/contracts/contracts/layer_1/interfaces/ERC1400/IERC1410Management.sol index 753b95aae..b4f60f3ce 100644 --- a/packages/ats/contracts/contracts/layer_1/interfaces/ERC1400/IERC1410Management.sol +++ b/packages/ats/contracts/contracts/layer_1/interfaces/ERC1400/IERC1410Management.sol @@ -4,6 +4,7 @@ pragma solidity >=0.8.0 <0.9.0; import { OperatorTransferData } from "../../../layer_1/interfaces/ERC1400/IERC1410.sol"; import { IssueData } from "../../../layer_1/interfaces/ERC1400/IERC1410.sol"; +import { IProtectedPartitionsStorageWrapper } from "../protectedPartitions/IProtectedPartitionsStorageWrapper.sol"; /** * @title IERC1410Management @@ -26,7 +27,7 @@ interface IERC1410Management { uint256 _value, bytes calldata _data, bytes calldata _operatorData - ) external; + ) external returns (bytes32); /** * @notice Forces a redeem in a partition from a token holder @@ -74,10 +75,8 @@ interface IERC1410Management { address _from, address _to, uint256 _amount, - uint256 _deadline, - uint256 _nounce, - bytes calldata _signature - ) external; + IProtectedPartitionsStorageWrapper.ProtectionData calldata _protectionData + ) external returns (bytes32); /** * @notice Redeems tokens from the token holder by presenting an off-chain signature @@ -87,8 +86,6 @@ interface IERC1410Management { bytes32 _partition, address _from, uint256 _amount, - uint256 _deadline, - uint256 _nounce, - bytes calldata _signature + IProtectedPartitionsStorageWrapper.ProtectionData calldata _protectionData ) external; } diff --git a/packages/ats/contracts/contracts/layer_1/interfaces/ERC1400/IERC1410StorageWrapper.sol b/packages/ats/contracts/contracts/layer_1/interfaces/ERC1400/IERC1410StorageWrapper.sol index 559f8787e..997ca3c6c 100644 --- a/packages/ats/contracts/contracts/layer_1/interfaces/ERC1400/IERC1410StorageWrapper.sol +++ b/packages/ats/contracts/contracts/layer_1/interfaces/ERC1400/IERC1410StorageWrapper.sol @@ -42,7 +42,6 @@ interface IERC1410StorageWrapper { error NotAllowedInMultiPartitionMode(); error PartitionNotAllowedInSinglePartitionMode(bytes32 partition); - error ZeroAddressNotAllowed(); error ZeroPartition(); error ZeroValue(); error InvalidPartition(address account, bytes32 partition); diff --git a/packages/ats/contracts/contracts/layer_1/interfaces/clearing/IClearingActions.sol b/packages/ats/contracts/contracts/layer_1/interfaces/clearing/IClearingActions.sol index 05aaf79bf..1afcb19f9 100644 --- a/packages/ats/contracts/contracts/layer_1/interfaces/clearing/IClearingActions.sol +++ b/packages/ats/contracts/contracts/layer_1/interfaces/clearing/IClearingActions.sol @@ -58,7 +58,7 @@ interface IClearingActions { */ function approveClearingOperationByPartition( IClearing.ClearingOperationIdentifier calldata _clearingOperationIdentifier - ) external returns (bool success_); + ) external returns (bool success_, bytes32 partition_); /** * @notice Cancels a clearing operation returning funds back to the token holder diff --git a/packages/ats/contracts/contracts/layer_1/interfaces/corporateActions/ICorporateActions.sol b/packages/ats/contracts/contracts/layer_1/interfaces/corporateActions/ICorporateActions.sol index c07034eb4..7b34647da 100644 --- a/packages/ats/contracts/contracts/layer_1/interfaces/corporateActions/ICorporateActions.sol +++ b/packages/ats/contracts/contracts/layer_1/interfaces/corporateActions/ICorporateActions.sol @@ -77,4 +77,6 @@ interface ICorporateActions { uint256 _pageIndex, uint256 _pageLength ) external view returns (bytes32[] memory corporateActionIds_); + + function actionContentHashExists(bytes32 _contentHash) external view returns (bool); } diff --git a/packages/ats/contracts/contracts/layer_1/interfaces/corporateActions/ICorporateActionsStorageWrapper.sol b/packages/ats/contracts/contracts/layer_1/interfaces/corporateActions/ICorporateActionsStorageWrapper.sol index aa689f38d..7eecf2d1e 100644 --- a/packages/ats/contracts/contracts/layer_1/interfaces/corporateActions/ICorporateActionsStorageWrapper.sol +++ b/packages/ats/contracts/contracts/layer_1/interfaces/corporateActions/ICorporateActionsStorageWrapper.sol @@ -13,6 +13,7 @@ struct CorporateActionDataStorage { EnumerableSet.Bytes32Set actions; mapping(bytes32 => ActionData) actionsData; mapping(bytes32 => EnumerableSet.Bytes32Set) actionsByType; + mapping(bytes32 => bool) actionsContentHashes; } interface ICorporateActionsStorageWrapper { diff --git a/packages/ats/contracts/contracts/layer_1/interfaces/hold/IHoldTokenHolder.sol b/packages/ats/contracts/contracts/layer_1/interfaces/hold/IHoldTokenHolder.sol index ca0b310cf..53640589d 100644 --- a/packages/ats/contracts/contracts/layer_1/interfaces/hold/IHoldTokenHolder.sol +++ b/packages/ats/contracts/contracts/layer_1/interfaces/hold/IHoldTokenHolder.sol @@ -79,7 +79,7 @@ interface IHoldTokenHolder { HoldIdentifier calldata _holdIdentifier, address _to, uint256 _amount - ) external returns (bool success_); + ) external returns (bool success_, bytes32 partition_); /** * @notice Releases the held tokens back to the token holde diff --git a/packages/ats/contracts/contracts/layer_1/interfaces/protectedPartitions/IProtectedPartitionsStorageWrapper.sol b/packages/ats/contracts/contracts/layer_1/interfaces/protectedPartitions/IProtectedPartitionsStorageWrapper.sol index a6ff5ddb9..c4569c2fb 100644 --- a/packages/ats/contracts/contracts/layer_1/interfaces/protectedPartitions/IProtectedPartitionsStorageWrapper.sol +++ b/packages/ats/contracts/contracts/layer_1/interfaces/protectedPartitions/IProtectedPartitionsStorageWrapper.sol @@ -2,6 +2,12 @@ pragma solidity >=0.8.0 <0.9.0; interface IProtectedPartitionsStorageWrapper { + struct ProtectionData { + uint256 deadline; + uint256 nounce; + bytes signature; + } + event PartitionsProtected(address indexed operator); event PartitionsUnProtected(address indexed operator); diff --git a/packages/ats/contracts/contracts/layer_2/equity/Equity.sol b/packages/ats/contracts/contracts/layer_2/equity/Equity.sol index 07d46deb8..953b56f46 100644 --- a/packages/ats/contracts/contracts/layer_2/equity/Equity.sol +++ b/packages/ats/contracts/contracts/layer_2/equity/Equity.sol @@ -184,7 +184,7 @@ abstract contract Equity is IEquity, Common { onlyMatchingActionType(BALANCE_ADJUSTMENT_CORPORATE_ACTION_TYPE, _balanceAdjustmentID - 1) returns (ScheduledBalanceAdjustment memory balanceAdjustment_) { - return _getScheduledBalanceAdjusment(_balanceAdjustmentID); + return _getScheduledBalanceAdjustment(_balanceAdjustmentID); } function getScheduledBalanceAdjustmentCount() external view override returns (uint256 balanceAdjustmentCount_) { diff --git a/packages/ats/contracts/contracts/layer_2/proceedRecipients/ProceedRecipients.sol b/packages/ats/contracts/contracts/layer_2/proceedRecipients/ProceedRecipients.sol index 7d18446d3..39b543110 100644 --- a/packages/ats/contracts/contracts/layer_2/proceedRecipients/ProceedRecipients.sol +++ b/packages/ats/contracts/contracts/layer_2/proceedRecipients/ProceedRecipients.sol @@ -14,6 +14,7 @@ contract ProceedRecipients is IProceedRecipients, Common { ) external override onlyUninitialized(_externalListStorage(_PROCEED_RECIPIENTS_STORAGE_POSITION).initialized) { uint256 length = _proceedRecipients.length; for (uint256 index; index < length; ) { + _checkValidAddress(_proceedRecipients[index]); _addExternalList(_PROCEED_RECIPIENTS_STORAGE_POSITION, _proceedRecipients[index]); _setProceedRecipientData(_proceedRecipients[index], _data[index]); unchecked { @@ -32,6 +33,7 @@ contract ProceedRecipients is IProceedRecipients, Common { override onlyUnpaused onlyRole(_PROCEED_RECIPIENT_MANAGER_ROLE) + validateAddress(_proceedRecipient) onlyIfNotProceedRecipient(_proceedRecipient) { _addProceedRecipient(_proceedRecipient, _data); @@ -59,6 +61,7 @@ contract ProceedRecipients is IProceedRecipients, Common { override onlyUnpaused onlyRole(_PROCEED_RECIPIENT_MANAGER_ROLE) + validateAddress(_proceedRecipient) onlyIfProceedRecipient(_proceedRecipient) { _setProceedRecipientData(_proceedRecipient, _data); diff --git a/packages/ats/contracts/contracts/layer_3/bondUSA/BondUSAReadFacet.sol b/packages/ats/contracts/contracts/layer_3/bondUSA/BondUSAReadFacet.sol index 8679ccc5a..0f3ce3414 100644 --- a/packages/ats/contracts/contracts/layer_3/bondUSA/BondUSAReadFacet.sol +++ b/packages/ats/contracts/contracts/layer_3/bondUSA/BondUSAReadFacet.sol @@ -29,7 +29,7 @@ contract BondUSAReadFacet is BondRead, Security { } function getStaticInterfaceIds() external pure override returns (bytes4[] memory staticInterfaceIds_) { - staticInterfaceIds_ = new bytes4[](3); + staticInterfaceIds_ = new bytes4[](2); uint256 selectorsIndex; staticInterfaceIds_[selectorsIndex++] = type(IBondRead).interfaceId; staticInterfaceIds_[selectorsIndex++] = type(ISecurity).interfaceId; diff --git a/packages/ats/contracts/contracts/layer_3/interfaces/ITransferAndLock.sol b/packages/ats/contracts/contracts/layer_3/interfaces/ITransferAndLock.sol index bf3c790c8..760e41b47 100644 --- a/packages/ats/contracts/contracts/layer_3/interfaces/ITransferAndLock.sol +++ b/packages/ats/contracts/contracts/layer_3/interfaces/ITransferAndLock.sol @@ -1,6 +1,10 @@ // SPDX-License-Identifier: Apache-2.0 pragma solidity >=0.8.0 <0.9.0; +import { + IProtectedPartitionsStorageWrapper +} from "../../layer_1/interfaces/protectedPartitions/IProtectedPartitionsStorageWrapper.sol"; + interface ITransferAndLock { struct TransferAndLockStruct { address from; @@ -46,16 +50,12 @@ interface ITransferAndLock { * @dev Can only be called by an account with the protected partitions role * @param _partition The partition from which tokens will be transferred and locked * @param _transferAndLockData The struct containing the transfer and lock data - * @param _deadline The deadline timestamp for the signature to be valid - * @param _nounce The nounce for the signature to be valid - * @param _signature The signature of the transfer and lock data + * @param _protectionData The protection dataure to be valid */ function protectedTransferAndLockByPartition( bytes32 _partition, TransferAndLockStruct calldata _transferAndLockData, - uint256 _deadline, - uint256 _nounce, - bytes calldata _signature + IProtectedPartitionsStorageWrapper.ProtectionData calldata _protectionData ) external returns (bool success_, uint256 lockId_); /** @@ -63,14 +63,10 @@ interface ITransferAndLock { * timestamp using the default partition * @dev Can only be called by an account with the protected partitions role * @param _transferAndLockData The struct containing the transfer and lock data - * @param _deadline The deadline timestamp for the signature to be valid - * @param _nounce The nounce for the signature to be valid - * @param _signature The signature of the transfer and lock data + * @param _protectionData The protection dataure to be valid */ function protectedTransferAndLock( TransferAndLockStruct calldata _transferAndLockData, - uint256 _deadline, - uint256 _nounce, - bytes calldata _signature + IProtectedPartitionsStorageWrapper.ProtectionData calldata _protectionData ) external returns (bool success_, uint256 lockId_); } diff --git a/packages/ats/contracts/contracts/layer_3/transferAndLock/TransferAndLock.sol b/packages/ats/contracts/contracts/layer_3/transferAndLock/TransferAndLock.sol index 0a89de303..9f9562a2a 100644 --- a/packages/ats/contracts/contracts/layer_3/transferAndLock/TransferAndLock.sol +++ b/packages/ats/contracts/contracts/layer_3/transferAndLock/TransferAndLock.sol @@ -7,6 +7,9 @@ import { ITransferAndLock } from "../interfaces/ITransferAndLock.sol"; import { BasicTransferInfo } from "../../layer_1/interfaces/ERC1400/IERC1410.sol"; import { Common } from "../../layer_1/common/Common.sol"; import { ITransferAndLock } from "../interfaces/ITransferAndLock.sol"; +import { + IProtectedPartitionsStorageWrapper +} from "../../layer_1/interfaces/protectedPartitions/IProtectedPartitionsStorageWrapper.sol"; abstract contract TransferAndLock is ITransferAndLock, Common { function transferAndLockByPartition( @@ -76,9 +79,7 @@ abstract contract TransferAndLock is ITransferAndLock, Common { function protectedTransferAndLockByPartition( bytes32 _partition, TransferAndLockStruct calldata _transferAndLockData, - uint256 _deadline, - uint256 _nounce, - bytes calldata _signature + IProtectedPartitionsStorageWrapper.ProtectionData calldata _protectionData ) external override @@ -90,14 +91,12 @@ abstract contract TransferAndLock is ITransferAndLock, Common { onlyProtectedPartitions returns (bool success_, uint256 lockId_) { - return _protectedTransferAndLockByPartition(_partition, _transferAndLockData, _deadline, _nounce, _signature); + return _protectedTransferAndLockByPartition(_partition, _transferAndLockData, _protectionData); } function protectedTransferAndLock( TransferAndLockStruct calldata _transferAndLockData, - uint256 _deadline, - uint256 _nounce, - bytes calldata _signature + IProtectedPartitionsStorageWrapper.ProtectionData calldata _protectionData ) external override @@ -109,6 +108,6 @@ abstract contract TransferAndLock is ITransferAndLock, Common { onlyProtectedPartitions returns (bool success_, uint256 lockId_) { - return _protectedTransferAndLock(_transferAndLockData, _deadline, _nounce, _signature); + return _protectedTransferAndLock(_transferAndLockData, _protectionData); } } diff --git a/packages/ats/contracts/contracts/resolver/diamondCutManager/DiamondCutManagerWrapper.sol b/packages/ats/contracts/contracts/resolver/diamondCutManager/DiamondCutManagerWrapper.sol index a41c8d048..81a5198aa 100644 --- a/packages/ats/contracts/contracts/resolver/diamondCutManager/DiamondCutManagerWrapper.sol +++ b/packages/ats/contracts/contracts/resolver/diamondCutManager/DiamondCutManagerWrapper.sol @@ -95,7 +95,6 @@ abstract contract DiamondCutManagerWrapper is IDiamondCutManager, BusinessLogicR address addr = _resolveBusinessLogicByVersion(facetId, facetVersion); - // TODO: is better a checkFacetRegistered in BusinessLogicResolverWrapper?? if (addr == address(0)) { revert FacetIdNotRegistered(_configurationId, facetId); } @@ -466,7 +465,6 @@ abstract contract DiamondCutManagerWrapper is IDiamondCutManager, BusinessLogicR } } - // TODO: Move to a separate file. function _buildHash(bytes32 _configurationId, uint256 _version) private pure returns (bytes32 hash_) { hash_ = keccak256(abi.encodePacked(_configurationId, _version)); } diff --git a/packages/ats/contracts/contracts/resolver/resolverProxy/facets/DiamondLoupeFacet.sol b/packages/ats/contracts/contracts/resolver/resolverProxy/facets/DiamondLoupeFacet.sol index fffa76b77..1337d55fe 100644 --- a/packages/ats/contracts/contracts/resolver/resolverProxy/facets/DiamondLoupeFacet.sol +++ b/packages/ats/contracts/contracts/resolver/resolverProxy/facets/DiamondLoupeFacet.sol @@ -9,7 +9,6 @@ import { IDiamondLoupe } from "../../../interfaces/resolver/resolverProxy/IDiamo import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import { _DIAMOND_LOUPE_RESOLVER_KEY } from "../../../layer_1/constants/resolverKeys.sol"; -// HACK: I think that Loupe and Cut implementation should be only one contract. contract DiamondLoupeFacet is IDiamondLoupe, IERC165, ResolverProxyUnstructured { function getFacets() external view override returns (Facet[] memory facets_) { ResolverProxyStorage storage ds = _resolverProxyStorage(); diff --git a/packages/ats/contracts/scripts/domain/atsRegistry.data.ts b/packages/ats/contracts/scripts/domain/atsRegistry.data.ts index 1950ff2f6..fd8564fb9 100644 --- a/packages/ats/contracts/scripts/domain/atsRegistry.data.ts +++ b/packages/ats/contracts/scripts/domain/atsRegistry.data.ts @@ -10,7 +10,7 @@ * * Import from '@scripts/domain' instead of this file directly. * - * Generated: 2025-12-01T14:53:46.712Z + * Generated: 2025-12-04T15:10:02.770Z * Facets: 49 * Infrastructure: 2 * @@ -512,6 +512,7 @@ export const FACET_REGISTRY: Record = { }, inheritance: ["CorporateActions", "IStaticFunctionSelectors"], methods: [ + { name: "actionContentHashExists", signature: "actionContentHashExists(bytes32)", selector: "0x14f1d784" }, { name: "addCorporateAction", signature: "addCorporateAction(bytes32,bytes)", selector: "0xd9e4d92c" }, { name: "getCorporateAction", signature: "getCorporateAction(bytes32)", selector: "0x911181da" }, { name: "getCorporateActionCount", signature: "getCorporateActionCount()", selector: "0x8859794c" }, @@ -630,6 +631,7 @@ export const FACET_REGISTRY: Record = { { name: "TokenIsPaused", signature: "TokenIsPaused()", selector: "0x649815a5" }, { name: "TokenIsUnpaused", signature: "TokenIsUnpaused()", selector: "0x72058d69" }, { name: "WrongSignature", signature: "WrongSignature()", selector: "0x356a4418" }, + { name: "ZeroAddressNotAllowed", signature: "ZeroAddressNotAllowed()", selector: "0x8579befe" }, { name: "ZeroKeyNotValidForBusinessLogic", signature: "ZeroKeyNotValidForBusinessLogic()", @@ -747,6 +749,7 @@ export const FACET_REGISTRY: Record = { { name: "TokenIsPaused", signature: "TokenIsPaused()", selector: "0x649815a5" }, { name: "TokenIsUnpaused", signature: "TokenIsUnpaused()", selector: "0x72058d69" }, { name: "WrongSignature", signature: "WrongSignature()", selector: "0x356a4418" }, + { name: "ZeroAddressNotAllowed", signature: "ZeroAddressNotAllowed()", selector: "0x8579befe" }, { name: "ZeroKeyNotValidForBusinessLogic", signature: "ZeroKeyNotValidForBusinessLogic()", @@ -856,6 +859,7 @@ export const FACET_REGISTRY: Record = { { name: "TokenIsPaused", signature: "TokenIsPaused()", selector: "0x649815a5" }, { name: "TokenIsUnpaused", signature: "TokenIsUnpaused()", selector: "0x72058d69" }, { name: "WrongSignature", signature: "WrongSignature()", selector: "0x356a4418" }, + { name: "ZeroAddressNotAllowed", signature: "ZeroAddressNotAllowed()", selector: "0x8579befe" }, { name: "ZeroKeyNotValidForBusinessLogic", signature: "ZeroKeyNotValidForBusinessLogic()", @@ -960,13 +964,15 @@ export const FACET_REGISTRY: Record = { }, { name: "protectedRedeemFromByPartition", - signature: "protectedRedeemFromByPartition(bytes32,address,uint256,uint256,uint256,bytes)", - selector: "0xc98d9723", + signature: + "protectedRedeemFromByPartition(bytes32,address,uint256,IProtectedPartitionsStorageWrapper.ProtectionData)", + selector: "0x648ad69d", }, { name: "protectedTransferFromByPartition", - signature: "protectedTransferFromByPartition(bytes32,address,address,uint256,uint256,uint256,bytes)", - selector: "0x12e41c0a", + signature: + "protectedTransferFromByPartition(bytes32,address,address,uint256,IProtectedPartitionsStorageWrapper.ProtectionData)", + selector: "0xf8edc4b5", }, ], factory: (signer, useTimeTravel = false) => @@ -2136,13 +2142,14 @@ export const FACET_REGISTRY: Record = { methods: [ { name: "protectedTransferAndLock", - signature: "protectedTransferAndLock(TransferAndLockStruct,uint256,uint256,bytes)", - selector: "0xaf33faac", + signature: "protectedTransferAndLock(TransferAndLockStruct,IProtectedPartitionsStorageWrapper.ProtectionData)", + selector: "0x51d4bc03", }, { name: "protectedTransferAndLockByPartition", - signature: "protectedTransferAndLockByPartition(bytes32,TransferAndLockStruct,uint256,uint256,bytes)", - selector: "0xbd2951ce", + signature: + "protectedTransferAndLockByPartition(bytes32,TransferAndLockStruct,IProtectedPartitionsStorageWrapper.ProtectionData)", + selector: "0xa2cf2efd", }, { name: "transferAndLock", signature: "transferAndLock(address,uint256,bytes,uint256)", selector: "0x0e92b90b" }, { @@ -2306,6 +2313,7 @@ export const STORAGE_WRAPPER_REGISTRY: Record name: "CorporateActionsStorageWrapper", inheritance: ["ClearingStorageWrapper1"], methods: [ + { name: "_actionContentHashExists", signature: "_actionContentHashExists(bytes32)", selector: "0x9e442b55" }, { name: "_addCorporateAction", signature: "_addCorporateAction(bytes32,bytes)", selector: "0xb2a57bb4" }, { name: "_checkDates", signature: "_checkDates(uint256,uint256)", selector: "0x970b0e20" }, { @@ -2363,9 +2371,9 @@ export const STORAGE_WRAPPER_REGISTRY: Record { name: "_getDividendsFor", signature: "_getDividendsFor(uint256,address)", selector: "0x5a1270c7" }, { name: "_getEquityDetails", signature: "_getEquityDetails()", selector: "0x3571999f" }, { - name: "_getScheduledBalanceAdjusment", - signature: "_getScheduledBalanceAdjusment(uint256)", - selector: "0xb2106163", + name: "_getScheduledBalanceAdjustment", + signature: "_getScheduledBalanceAdjustment(uint256)", + selector: "0x6d94b10c", }, { name: "_getScheduledBalanceAdjustmentsCount", @@ -2467,13 +2475,15 @@ export const STORAGE_WRAPPER_REGISTRY: Record methods: [ { name: "_protectedRedeemFromByPartition", - signature: "_protectedRedeemFromByPartition(bytes32,address,uint256,uint256,uint256,bytes)", - selector: "0x6d27f455", + signature: + "_protectedRedeemFromByPartition(bytes32,address,uint256,IProtectedPartitionsStorageWrapper.ProtectionData)", + selector: "0xa0d2a3c0", }, { name: "_protectedTransferFromByPartition", - signature: "_protectedTransferFromByPartition(bytes32,address,address,uint256,uint256,uint256,bytes)", - selector: "0xfac1472b", + signature: + "_protectedTransferFromByPartition(bytes32,address,address,uint256,IProtectedPartitionsStorageWrapper.ProtectionData)", + selector: "0x5bda1de2", }, ], }, @@ -2727,6 +2737,7 @@ export const STORAGE_WRAPPER_REGISTRY: Record inheritance: ["SsiManagementStorageWrapper"], methods: [ { name: "_addExternalList", signature: "_addExternalList(bytes32,address)", selector: "0x7b548517" }, + { name: "_checkValidAddress", signature: "_checkValidAddress(address)", selector: "0x42d56018" }, { name: "_externalListStorage", signature: "_externalListStorage(bytes32)", selector: "0x4c938df7" }, { name: "_getExternalListsCount", signature: "_getExternalListsCount(bytes32)", selector: "0x91794627" }, { @@ -2742,6 +2753,7 @@ export const STORAGE_WRAPPER_REGISTRY: Record selector: "0x7b9dc6c3", }, ], + errors: [{ name: "ZeroAddressNotAllowed", signature: "ZeroAddressNotAllowed()", selector: "0x8579befe" }], }, ExternalPauseManagementStorageWrapper: { @@ -2839,14 +2851,15 @@ export const STORAGE_WRAPPER_REGISTRY: Record { name: "_checkProtectedPartitions", signature: "_checkProtectedPartitions()", selector: "0xed6f719a" }, { name: "_checkRedeemSignature", - signature: "_checkRedeemSignature(bytes32,address,uint256,uint256,uint256,bytes)", - selector: "0x2546b4b4", + signature: "_checkRedeemSignature(bytes32,address,uint256,IProtectedPartitionsStorageWrapper.ProtectionData)", + selector: "0x86f1789d", }, { name: "_checkRoleForPartition", signature: "_checkRoleForPartition(bytes32,address)", selector: "0x67323be5" }, { name: "_checkTransferSignature", - signature: "_checkTransferSignature(bytes32,address,address,uint256,uint256,uint256,bytes)", - selector: "0x6ee3d1e2", + signature: + "_checkTransferSignature(bytes32,address,address,uint256,IProtectedPartitionsStorageWrapper.ProtectionData)", + selector: "0x75734433", }, { name: "_checkValidPartition", signature: "_checkValidPartition(bytes32)", selector: "0x836740a4" }, { name: "_getNounceFor", signature: "_getNounceFor(address)", selector: "0x795a18cb" }, @@ -2872,13 +2885,14 @@ export const STORAGE_WRAPPER_REGISTRY: Record }, { name: "_isRedeemSignatureValid", - signature: "_isRedeemSignatureValid(bytes32,address,uint256,uint256,uint256,bytes)", - selector: "0x21058b93", + signature: "_isRedeemSignatureValid(bytes32,address,uint256,IProtectedPartitionsStorageWrapper.ProtectionData)", + selector: "0xf603fc7b", }, { name: "_isTransferSignatureValid", - signature: "_isTransferSignatureValid(bytes32,address,address,uint256,uint256,uint256,bytes)", - selector: "0x30a87935", + signature: + "_isTransferSignatureValid(bytes32,address,address,uint256,IProtectedPartitionsStorageWrapper.ProtectionData)", + selector: "0x006444f7", }, { name: "_protectedPartitionsRole", signature: "_protectedPartitionsRole(bytes32)", selector: "0xde41fe7d" }, { name: "_protectedPartitionsStorage", signature: "_protectedPartitionsStorage()", selector: "0x00840cb7" }, @@ -3072,35 +3086,38 @@ export const STORAGE_WRAPPER_REGISTRY: Record { name: "_checkTransferAndLockByPartitionSignature", signature: - "_checkTransferAndLockByPartitionSignature(bytes32,ITransferAndLock.TransferAndLockStruct,uint256,uint256,bytes)", - selector: "0xa89ed8df", + "_checkTransferAndLockByPartitionSignature(bytes32,ITransferAndLock.TransferAndLockStruct,IProtectedPartitionsStorageWrapper.ProtectionData)", + selector: "0x0ecc448e", }, { name: "_checkTransferAndLockSignature", - signature: "_checkTransferAndLockSignature(ITransferAndLock.TransferAndLockStruct,uint256,uint256,bytes)", - selector: "0x8a1708d9", + signature: + "_checkTransferAndLockSignature(ITransferAndLock.TransferAndLockStruct,IProtectedPartitionsStorageWrapper.ProtectionData)", + selector: "0x47053ca4", }, { name: "_isTransferAndLockByPartitionSignatureValid", signature: - "_isTransferAndLockByPartitionSignatureValid(bytes32,ITransferAndLock.TransferAndLockStruct,uint256,uint256,bytes)", - selector: "0x8b429f59", + "_isTransferAndLockByPartitionSignatureValid(bytes32,ITransferAndLock.TransferAndLockStruct,IProtectedPartitionsStorageWrapper.ProtectionData)", + selector: "0xd862c589", }, { name: "_isTransferAndLockSignatureValid", - signature: "_isTransferAndLockSignatureValid(ITransferAndLock.TransferAndLockStruct,uint256,uint256,bytes)", - selector: "0x6274de2d", + signature: + "_isTransferAndLockSignatureValid(ITransferAndLock.TransferAndLockStruct,IProtectedPartitionsStorageWrapper.ProtectionData)", + selector: "0x1f7ea122", }, { name: "_protectedTransferAndLock", - signature: "_protectedTransferAndLock(ITransferAndLock.TransferAndLockStruct,uint256,uint256,bytes)", - selector: "0x108b43ed", + signature: + "_protectedTransferAndLock(ITransferAndLock.TransferAndLockStruct,IProtectedPartitionsStorageWrapper.ProtectionData)", + selector: "0xb5da390a", }, { name: "_protectedTransferAndLockByPartition", signature: - "_protectedTransferAndLockByPartition(bytes32,ITransferAndLock.TransferAndLockStruct,uint256,uint256,bytes)", - selector: "0x472a5931", + "_protectedTransferAndLockByPartition(bytes32,ITransferAndLock.TransferAndLockStruct,IProtectedPartitionsStorageWrapper.ProtectionData)", + selector: "0x94e698c1", }, ], }, diff --git a/packages/ats/contracts/test/contracts/unit/layer_1/ERC3643/erc3643.test.ts b/packages/ats/contracts/test/contracts/unit/layer_1/ERC3643/erc3643.test.ts index 9d5f39267..179cabc76 100644 --- a/packages/ats/contracts/test/contracts/unit/layer_1/ERC3643/erc3643.test.ts +++ b/packages/ats/contracts/test/contracts/unit/layer_1/ERC3643/erc3643.test.ts @@ -1461,6 +1461,32 @@ describe("ERC3643 Tests", () => { ).to.be.revertedWithCustomError(controlList, "AccountIsBlocked"); }); + it("GIVEN paused token WHEN batchSetAddressFrozen THEN fails with TokenIsPaused", async () => { + const userAddresses = [signer_D.address, signer_E.address]; + // grant KYC to signer_A.address + await kycFacet.grantKyc(signer_A.address, EMPTY_VC_ID, ZERO, MAX_UINT256, signer_E.address); + + await pauseFacet.connect(signer_B).pause(); + + // First, freeze the addresses + await expect(freezeFacet.batchSetAddressFrozen(userAddresses, [true, true])).to.revertedWithCustomError( + pauseFacet, + "TokenIsPaused", + ); + }); + + it("GIVEN invalid address WHEN batchSetAddressFrozen THEN fails with ZeroAddressNotAllowed", async () => { + const userAddresses = [signer_D.address, signer_E.address, ADDRESS_ZERO]; + // grant KYC to signer_A.address + await kycFacet.grantKyc(signer_A.address, EMPTY_VC_ID, ZERO, MAX_UINT256, signer_E.address); + + // First, freeze the addresses + await expect(freezeFacet.batchSetAddressFrozen(userAddresses, [true, true, true])).to.revertedWithCustomError( + freezeFacet, + "ZeroAddressNotAllowed", + ); + }); + it("GIVEN frozen addresses WHEN batchSetAddressFrozen with false THEN transfers from those addresses succeed", async () => { const userAddresses = [signer_D.address, signer_E.address]; // grant KYC to signer_A.address @@ -1955,15 +1981,11 @@ describe("ERC3643 Tests", () => { await accessControlFacet.grantRole(ProtectedPartitionRole_1, signer_A.address); await protectedPartitionsFacet.protectPartitions(); await expect( - erc1410Facet.protectedTransferFromByPartition( - DEFAULT_PARTITION, - signer_C.address, - signer_B.address, - amount, - MAX_UINT256, - 1, - "0x1234", - ), + erc1410Facet.protectedTransferFromByPartition(DEFAULT_PARTITION, signer_C.address, signer_B.address, amount, { + deadline: MAX_UINT256, + nounce: 1, + signature: "0x1234", + }), ).to.be.revertedWithCustomError(erc3643Facet, "WalletRecovered"); await protectedPartitionsFacet.unprotectPartitions(); const operatorTransferData = { @@ -2017,15 +2039,11 @@ describe("ERC3643 Tests", () => { ); await protectedPartitionsFacet.protectPartitions(); await expect( - erc1410Facet.protectedTransferFromByPartition( - DEFAULT_PARTITION, - signer_B.address, - signer_C.address, - amount, - MAX_UINT256, - 1, - "0x1234", - ), + erc1410Facet.protectedTransferFromByPartition(DEFAULT_PARTITION, signer_B.address, signer_C.address, amount, { + deadline: MAX_UINT256, + nounce: 1, + signature: "0x1234", + }), ).to.be.revertedWithCustomError(erc3643Facet, "WalletRecovered"); await protectedPartitionsFacet.unprotectPartitions(); operatorTransferData.to = signer_C.address; @@ -2083,14 +2101,11 @@ describe("ERC3643 Tests", () => { ); await protectedPartitionsFacet.protectPartitions(); await expect( - erc1410Facet.protectedRedeemFromByPartition( - DEFAULT_PARTITION, - signer_C.address, - amount, - MAX_UINT256, - 1, - "0x1234", - ), + erc1410Facet.protectedRedeemFromByPartition(DEFAULT_PARTITION, signer_C.address, amount, { + deadline: MAX_UINT256, + nounce: 1, + signature: "0x1234", + }), ).to.be.revertedWithCustomError(erc3643Facet, "WalletRecovered"); await protectedPartitionsFacet.unprotectPartitions(); await expect( diff --git a/packages/ats/contracts/test/contracts/unit/layer_1/corporateActions/corporateActions.test.ts b/packages/ats/contracts/test/contracts/unit/layer_1/corporateActions/corporateActions.test.ts index 35cc18641..8e9f93248 100644 --- a/packages/ats/contracts/test/contracts/unit/layer_1/corporateActions/corporateActions.test.ts +++ b/packages/ats/contracts/test/contracts/unit/layer_1/corporateActions/corporateActions.test.ts @@ -68,8 +68,15 @@ describe("Corporate Actions Tests", () => { ); }); - it("GIVEN an account with corporateActions role WHEN addCorporateAction THEN transaction succeeds", async () => { + it("GIVEN an account with corporateActions role WHEN addCorporateAction (two identical CA) THEN transaction first succeeds but second fails with DuplicatedCorporateAction", async () => { await accessControlFacet.connect(signer_A).grantRole(ATS_ROLES._CORPORATE_ACTION_ROLE, signer_C.address); + + const encoded = ethers.utils.defaultAbiCoder.encode(["bytes32", "bytes"], [actionType, actionData]); + + const contentHash = ethers.utils.keccak256(encoded); + + const actionContentHashExistsBefore = await corporateActionsFacet.actionContentHashExists(contentHash); + // add to list await corporateActionsFacet.connect(signer_C).addCorporateAction(actionType, actionData); @@ -79,6 +86,7 @@ describe("Corporate Actions Tests", () => { const listCountByType = await corporateActionsFacet.getCorporateActionCountByType(actionType); const listMembersByType = await corporateActionsFacet.getCorporateActionIdsByType(actionType, 0, listCount); const corporateAction = await corporateActionsFacet.getCorporateAction(corporateActionId_1); + const actionContentHashExistsAfter = await corporateActionsFacet.actionContentHashExists(contentHash); expect(listCount).to.equal(1); expect(listMembers.length).to.equal(listCount); @@ -88,5 +96,11 @@ describe("Corporate Actions Tests", () => { expect(listMembersByType[0]).to.equal(corporateActionId_1); expect(corporateAction[0].toUpperCase()).to.equal(actionType.toUpperCase()); expect(corporateAction[1].toUpperCase()).to.equal(actionData.toUpperCase()); + expect(actionContentHashExistsBefore).to.be.false; + expect(actionContentHashExistsAfter).to.be.true; + + await expect( + corporateActionsFacet.connect(signer_C).addCorporateAction(actionType, actionData), + ).to.revertedWithCustomError(corporateActionsFacet, "DuplicatedCorporateAction"); }); }); diff --git a/packages/ats/contracts/test/contracts/unit/layer_1/externalControlLists/externalControlList.test.ts b/packages/ats/contracts/test/contracts/unit/layer_1/externalControlLists/externalControlList.test.ts index 496255db2..f654b055a 100644 --- a/packages/ats/contracts/test/contracts/unit/layer_1/externalControlLists/externalControlList.test.ts +++ b/packages/ats/contracts/test/contracts/unit/layer_1/externalControlLists/externalControlList.test.ts @@ -4,7 +4,7 @@ import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers.js"; import { ExternalControlListManagement, MockedWhitelist, MockedBlacklist, ResolverProxy } from "@contract-types"; import { loadFixture } from "@nomicfoundation/hardhat-network-helpers"; import { deployEquityTokenFixture } from "@test"; -import { ATS_ROLES, GAS_LIMIT } from "@scripts"; +import { ADDRESS_ZERO, ATS_ROLES, GAS_LIMIT } from "@scripts"; describe("ExternalControlList Management Tests", () => { let signer_A: SignerWithAddress; @@ -82,6 +82,14 @@ describe("ExternalControlList Management Tests", () => { }), ).to.be.revertedWithCustomError(externalControlListManagement, "ListedControlList"); }); + + it("GIVEN an invalid address WHEN adding it THEN it reverts with ZeroAddressNotAllowed", async () => { + await expect( + externalControlListManagement.addExternalControlList(ADDRESS_ZERO, { + gasLimit: GAS_LIMIT.default, + }), + ).to.be.revertedWithCustomError(externalControlListManagement, "ZeroAddressNotAllowed"); + }); }); describe("Remove Tests", () => { @@ -112,6 +120,17 @@ describe("ExternalControlList Management Tests", () => { }); describe("Update Tests", () => { + it("GIVEN invalid address WHEN updated THEN it reverts with ZeroAddressNotAllowed", async () => { + const controlLists = [ADDRESS_ZERO]; + const actives = [true]; + + await expect( + externalControlListManagement.updateExternalControlLists(controlLists, actives, { + gasLimit: GAS_LIMIT.high, + }), + ).to.be.revertedWithCustomError(externalControlListManagement, "ZeroAddressNotAllowed"); + }); + it("GIVEN multiple external control lists WHEN updated THEN their statuses are updated and event is emitted", async () => { expect(await externalControlListManagement.isExternalControlList(externalWhitelistMock1.address)).to.be.true; expect(await externalControlListManagement.isExternalControlList(externalBlacklistMock1.address)).to.be.true; diff --git a/packages/ats/contracts/test/contracts/unit/layer_1/externalKycLists/externalKycList.test.ts b/packages/ats/contracts/test/contracts/unit/layer_1/externalKycLists/externalKycList.test.ts index de4691150..7b02c23dd 100644 --- a/packages/ats/contracts/test/contracts/unit/layer_1/externalKycLists/externalKycList.test.ts +++ b/packages/ats/contracts/test/contracts/unit/layer_1/externalKycLists/externalKycList.test.ts @@ -1,7 +1,7 @@ import { expect } from "chai"; import { ethers } from "hardhat"; import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers.js"; -import { ATS_ROLES, GAS_LIMIT } from "@scripts"; +import { ADDRESS_ZERO, ATS_ROLES, GAS_LIMIT } from "@scripts"; import { deployEquityTokenFixture } from "@test"; import { ResolverProxy, ExternalKycListManagement, MockedExternalKycList } from "@contract-types"; import { loadFixture } from "@nomicfoundation/hardhat-network-helpers"; @@ -68,6 +68,14 @@ describe("ExternalKycList Management Tests", () => { externalKycListManagement.addExternalKycList(externalKycListMock1.address, { gasLimit: GAS_LIMIT.default }), ).to.be.revertedWithCustomError(externalKycListManagement, "ListedKycList"); }); + + it("GIVEN an invalid address WHEN adding it THEN it reverts with ZeroAddressNotAllowed", async () => { + await expect( + externalKycListManagement.addExternalKycList(ADDRESS_ZERO, { + gasLimit: GAS_LIMIT.default, + }), + ).to.be.revertedWithCustomError(externalKycListManagement, "ZeroAddressNotAllowed"); + }); }); describe("Remove Tests", () => { @@ -98,6 +106,17 @@ describe("ExternalKycList Management Tests", () => { }); describe("Update Tests", () => { + it("GIVEN invalid address WHEN updated THEN it reverts with ZeroAddressNotAllowed", async () => { + const kycListsToUpdate = [ADDRESS_ZERO]; + const actives = [true]; + + await expect( + externalKycListManagement.updateExternalKycLists(kycListsToUpdate, actives, { + gasLimit: GAS_LIMIT.high, + }), + ).to.be.revertedWithCustomError(externalKycListManagement, "ZeroAddressNotAllowed"); + }); + it("GIVEN multiple external kyc WHEN updated THEN their statuses are updated and event is emitted", async () => { expect(await externalKycListManagement.isExternalKycList(externalKycListMock1.address)).to.be.true; expect(await externalKycListManagement.isExternalKycList(externalKycListMock2.address)).to.be.true; diff --git a/packages/ats/contracts/test/contracts/unit/layer_1/externalPauses/externalPause.test.ts b/packages/ats/contracts/test/contracts/unit/layer_1/externalPauses/externalPause.test.ts index 98ae4eaf1..c014cfa41 100644 --- a/packages/ats/contracts/test/contracts/unit/layer_1/externalPauses/externalPause.test.ts +++ b/packages/ats/contracts/test/contracts/unit/layer_1/externalPauses/externalPause.test.ts @@ -2,7 +2,7 @@ import { expect } from "chai"; import { ethers } from "hardhat"; import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers.js"; import { loadFixture } from "@nomicfoundation/hardhat-network-helpers"; -import { ATS_ROLES, GAS_LIMIT } from "@scripts"; +import { ADDRESS_ZERO, ATS_ROLES, GAS_LIMIT } from "@scripts"; import { deployEquityTokenFixture } from "@test"; import { ResolverProxy, ExternalPauseManagement, MockedExternalPause } from "@contract-types"; @@ -88,6 +88,14 @@ describe("ExternalPause Tests", () => { }), ).to.be.revertedWithCustomError(externalPauseManagement, "ListedPause"); }); + + it("GIVEN an invalid address WHEN adding it THEN it reverts with ZeroAddressNotAllowed", async () => { + await expect( + externalPauseManagement.addExternalPause(ADDRESS_ZERO, { + gasLimit: GAS_LIMIT.default, + }), + ).to.be.revertedWithCustomError(externalPauseManagement, "ZeroAddressNotAllowed"); + }); }); describe("Remove Tests", () => { @@ -118,6 +126,17 @@ describe("ExternalPause Tests", () => { }); describe("Update Tests", () => { + it("GIVEN invalid address WHEN updated THEN it reverts with ZeroAddressNotAllowed", async () => { + const pausesToUpdate = [ADDRESS_ZERO]; + const actives = [true]; + + await expect( + externalPauseManagement.updateExternalPauses(pausesToUpdate, actives, { + gasLimit: GAS_LIMIT.high, + }), + ).to.be.revertedWithCustomError(externalPauseManagement, "ZeroAddressNotAllowed"); + }); + it("GIVEN multiple external pauses WHEN updated THEN their statuses are updated and event is emitted", async () => { // Initial state: mock1=true, mock2=true. Verify. expect(await externalPauseManagement.isExternalPause(externalPauseMock1.address)).to.be.true; diff --git a/packages/ats/contracts/test/contracts/unit/layer_1/hold/hold.test.ts b/packages/ats/contracts/test/contracts/unit/layer_1/hold/hold.test.ts index 815c040ca..3da01f716 100644 --- a/packages/ats/contracts/test/contracts/unit/layer_1/hold/hold.test.ts +++ b/packages/ats/contracts/test/contracts/unit/layer_1/hold/hold.test.ts @@ -7,7 +7,6 @@ import { executeRbac, MAX_UINT256 } from "@test"; import { EMPTY_STRING, ATS_ROLES, ZERO, EMPTY_HEX_BYTES, ADDRESS_ZERO, dateToUnixTimestamp } from "@scripts"; import { ResolverProxy, - IHold, Pause, IERC1410, ControlList, @@ -23,6 +22,7 @@ import { Lock, Snapshots, } from "@contract-types"; +import { Contract } from "ethers"; const _DEFAULT_PARTITION = "0x0000000000000000000000000000000000000000000000000000000000000001"; const _WRONG_PARTITION = "0x0000000000000000000000000000000000000000000000000000000000000321"; @@ -58,7 +58,7 @@ describe("Hold Tests", () => { let signer_D: SignerWithAddress; let signer_E: SignerWithAddress; - let holdFacet: IHold; + let holdFacet: Contract; let pauseFacet: Pause; let lock: Lock; let erc1410Facet: IERC1410; @@ -119,8 +119,28 @@ describe("Hold Tests", () => { } async function setFacets({ diamond }: { diamond: ResolverProxy }) { + const holdManagementFacet = await ethers.getContractAt("HoldManagementFacet", diamond.address, signer_A); + + const holdReadFacet = await ethers.getContractAt("HoldReadFacet", diamond.address, signer_A); + const holdTokenHolderFacet = await ethers.getContractAt("HoldTokenHolderFacet", diamond.address, signer_A); + + const fragmentMap = new Map(); + [ + ...holdManagementFacet.interface.fragments, + ...holdReadFacet.interface.fragments, + ...holdTokenHolderFacet.interface.fragments, + ].forEach((fragment) => { + const key = fragment.format(); + if (!fragmentMap.has(key)) { + fragmentMap.set(key, fragment); + } + }); + + const uniqueFragments = Array.from(fragmentMap.values()); + + holdFacet = new Contract(diamond.address, uniqueFragments, signer_A); + lock = await ethers.getContractAt("Lock", diamond.address, signer_A); - holdFacet = await ethers.getContractAt("IHold", diamond.address, signer_A); pauseFacet = await ethers.getContractAt("Pause", diamond.address, signer_D); erc1410Facet = await ethers.getContractAt("IERC1410", diamond.address, signer_B); kycFacet = await ethers.getContractAt("Kyc", diamond.address, signer_B); diff --git a/packages/ats/contracts/test/contracts/unit/layer_1/proceedRecipients/proceedRecipients.test.ts b/packages/ats/contracts/test/contracts/unit/layer_1/proceedRecipients/proceedRecipients.test.ts index 267234df6..c957d5118 100644 --- a/packages/ats/contracts/test/contracts/unit/layer_1/proceedRecipients/proceedRecipients.test.ts +++ b/packages/ats/contracts/test/contracts/unit/layer_1/proceedRecipients/proceedRecipients.test.ts @@ -2,7 +2,7 @@ import { expect } from "chai"; import { ethers } from "hardhat"; import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers.js"; import { ProceedRecipients, ResolverProxy, AccessControl, Pause } from "@contract-types"; -import { GAS_LIMIT, ATS_ROLES } from "@scripts"; +import { GAS_LIMIT, ATS_ROLES, ADDRESS_ZERO } from "@scripts"; import { deployBondTokenFixture } from "@test"; import { loadFixture } from "@nomicfoundation/hardhat-network-helpers"; @@ -105,6 +105,14 @@ describe("Proceed Recipients Tests", () => { PROCEED_RECIPIENT_1, ]); }); + + it("GIVEN an invalid address WHEN adding it THEN it reverts with ZeroAddressNotAllowed", async () => { + await expect( + proceedRecipientsFacet.addProceedRecipient(ADDRESS_ZERO, PROCEED_RECIPIENT_1_DATA, { + gasLimit: GAS_LIMIT.default, + }), + ).to.be.revertedWithCustomError(proceedRecipientsFacet, "ZeroAddressNotAllowed"); + }); }); describe("Remove Tests", () => { @@ -151,6 +159,14 @@ describe("Proceed Recipients Tests", () => { }); describe("Update Data Tests", () => { + it("GIVEN invalid address WHEN updated THEN it reverts with ZeroAddressNotAllowed", async () => { + await expect( + proceedRecipientsFacet.updateProceedRecipientData(ADDRESS_ZERO, "0x", { + gasLimit: GAS_LIMIT.high, + }), + ).to.be.revertedWithCustomError(proceedRecipientsFacet, "ZeroAddressNotAllowed"); + }); + it("GIVEN a listed proceed recipient WHEN unauthorized user updates its data THEN it reverts with AccountHasNoRole", async () => { await expect( proceedRecipientsFacet diff --git a/packages/ats/contracts/test/contracts/unit/layer_1/protectedPartitions/protectedPartitions.test.ts b/packages/ats/contracts/test/contracts/unit/layer_1/protectedPartitions/protectedPartitions.test.ts index 257794cfe..bc3f3cc37 100644 --- a/packages/ats/contracts/test/contracts/unit/layer_1/protectedPartitions/protectedPartitions.test.ts +++ b/packages/ats/contracts/test/contracts/unit/layer_1/protectedPartitions/protectedPartitions.test.ts @@ -13,7 +13,6 @@ import { ControlList, Kyc, SsiManagement, - IHold, ComplianceMock, } from "@contract-types"; import { DEFAULT_PARTITION, ZERO, EMPTY_STRING, ADDRESS_ZERO, ATS_ROLES } from "@scripts"; @@ -219,7 +218,7 @@ describe("ProtectedPartitions Tests", () => { let accessControlFacet: AccessControl; let kycFacet: Kyc; let ssiManagementFacet: SsiManagement; - let holdFacet: IHold; + let holdFacet: Contract; let clearingFacet: Contract; let protectedHold: ProtectedHoldData; let hold: HoldData; @@ -249,6 +248,27 @@ describe("ProtectedPartitions Tests", () => { } async function setFacets(address: string, compliance?: string) { + const holdManagementFacet = await ethers.getContractAt("HoldManagementFacet", address, signer_A); + + const holdReadFacet = await ethers.getContractAt("HoldReadFacet", address, signer_A); + const holdTokenHolderFacet = await ethers.getContractAt("HoldTokenHolderFacet", address, signer_A); + + const fragmentMapHold = new Map(); + [ + ...holdManagementFacet.interface.fragments, + ...holdReadFacet.interface.fragments, + ...holdTokenHolderFacet.interface.fragments, + ].forEach((fragment) => { + const key = fragment.format(); + if (!fragmentMapHold.has(key)) { + fragmentMapHold.set(key, fragment); + } + }); + + const uniqueFragmentsHold = Array.from(fragmentMapHold.values()); + + holdFacet = new Contract(address, uniqueFragmentsHold, signer_A); + protectedPartitionsFacet = await ethers.getContractAt("ProtectedPartitions", address); pauseFacet = await ethers.getContractAt("Pause", address); erc1410Facet = await ethers.getContractAt("IERC1410", address); @@ -257,7 +277,6 @@ describe("ProtectedPartitions Tests", () => { transferAndLockFacet = await ethers.getContractAt("TransferAndLock", address); controlListFacet = await ethers.getContractAt("ControlList", address); accessControlFacet = await ethers.getContractAt("AccessControl", address); - holdFacet = await ethers.getContractAt("IHold", address); kycFacet = await ethers.getContractAt("Kyc", address); ssiManagementFacet = await ethers.getContractAt("SsiManagement", address); const clearingTransferFacet = await ethers.getContractAt("ClearingTransferFacet", address, signer_A); @@ -267,7 +286,7 @@ describe("ProtectedPartitions Tests", () => { const clearingReadFacet = await ethers.getContractAt("ClearingReadFacet", address, signer_A); const clearingActionsFacet = await ethers.getContractAt("ClearingActionsFacet", address, signer_A); - const fragmentMap = new Map(); + const fragmentMapClearing = new Map(); [ ...clearingTransferFacet.interface.fragments, ...clearingRedeemFacet.interface.fragments, @@ -276,14 +295,14 @@ describe("ProtectedPartitions Tests", () => { ...clearingActionsFacet.interface.fragments, ].forEach((fragment) => { const key = fragment.format(); - if (!fragmentMap.has(key)) { - fragmentMap.set(key, fragment); + if (!fragmentMapClearing.has(key)) { + fragmentMapClearing.set(key, fragment); } }); - const uniqueFragments = Array.from(fragmentMap.values()); + const uniqueFragmentsClearing = Array.from(fragmentMapClearing.values()); - clearingFacet = new Contract(address, uniqueFragments, signer_A); + clearingFacet = new Contract(address, uniqueFragmentsClearing, signer_A); if (compliance) { complianceMock = await ethers.getContractAt("ComplianceMock", compliance); @@ -459,15 +478,11 @@ describe("ProtectedPartitions Tests", () => { await pauseFacet.connect(signer_B).pause(); await expect( - erc1410Facet.protectedTransferFromByPartition( - DEFAULT_PARTITION, - signer_A.address, - signer_B.address, - amount, - MAX_UINT256, - 1, - "0x1234", - ), + erc1410Facet.protectedTransferFromByPartition(DEFAULT_PARTITION, signer_A.address, signer_B.address, amount, { + deadline: MAX_UINT256, + nounce: 1, + signature: "0x1234", + }), ).to.be.revertedWithCustomError(pauseFacet, "TokenIsPaused"); }); @@ -477,15 +492,11 @@ describe("ProtectedPartitions Tests", () => { await clearingFacet.activateClearing(); await expect( - erc1410Facet.protectedTransferFromByPartition( - DEFAULT_PARTITION, - signer_A.address, - signer_B.address, - amount, - MAX_UINT256, - 1, - "0x1234", - ), + erc1410Facet.protectedTransferFromByPartition(DEFAULT_PARTITION, signer_A.address, signer_B.address, amount, { + deadline: MAX_UINT256, + nounce: 1, + signature: "0x1234", + }), ).to.be.revertedWithCustomError(clearingFacet, "ClearingIsActivated"); }); @@ -493,15 +504,11 @@ describe("ProtectedPartitions Tests", () => { await setProtected(); await expect( - erc1410Facet.protectedTransferFromByPartition( - DEFAULT_PARTITION, - signer_A.address, - signer_B.address, - amount, - MAX_UINT256, - 1, - "0x1234", - ), + erc1410Facet.protectedTransferFromByPartition(DEFAULT_PARTITION, signer_A.address, signer_B.address, amount, { + deadline: MAX_UINT256, + nounce: 1, + signature: "0x1234", + }), ).to.be.rejectedWith("AccountHasNoRole"); }); @@ -513,15 +520,11 @@ describe("ProtectedPartitions Tests", () => { await expect( erc1410Facet .connect(signer_B) - .protectedTransferFromByPartition( - DEFAULT_PARTITION, - signer_A.address, - signer_B.address, - amount, - MAX_UINT256, - 1, - "0x1234", - ), + .protectedTransferFromByPartition(DEFAULT_PARTITION, signer_A.address, signer_B.address, amount, { + deadline: MAX_UINT256, + nounce: 1, + signature: "0x1234", + }), ).to.be.revertedWithCustomError(controlListFacet, "AccountIsBlocked"); }); @@ -533,15 +536,11 @@ describe("ProtectedPartitions Tests", () => { await expect( erc1410Facet .connect(signer_B) - .protectedTransferFromByPartition( - DEFAULT_PARTITION, - signer_A.address, - signer_B.address, - amount, - MAX_UINT256, - 1, - "0x1234", - ), + .protectedTransferFromByPartition(DEFAULT_PARTITION, signer_A.address, signer_B.address, amount, { + deadline: MAX_UINT256, + nounce: 1, + signature: "0x1234", + }), ).to.be.revertedWithCustomError(controlListFacet, "AccountIsBlocked"); }); @@ -553,29 +552,21 @@ describe("ProtectedPartitions Tests", () => { await expect( erc1410Facet .connect(signer_B) - .protectedTransferFromByPartition( - DEFAULT_PARTITION, - signer_A.address, - signer_B.address, - amount, - MAX_UINT256, - 1, - "0x1234", - ), + .protectedTransferFromByPartition(DEFAULT_PARTITION, signer_A.address, signer_B.address, amount, { + deadline: MAX_UINT256, + nounce: 1, + signature: "0x1234", + }), ).to.be.revertedWithCustomError(kycFacet, "InvalidKycStatus"); await expect( erc1410Facet .connect(signer_B) - .protectedTransferFromByPartition( - DEFAULT_PARTITION, - signer_B.address, - signer_A.address, - amount, - MAX_UINT256, - 1, - "0x1234", - ), + .protectedTransferFromByPartition(DEFAULT_PARTITION, signer_B.address, signer_A.address, amount, { + deadline: MAX_UINT256, + nounce: 1, + signature: "0x1234", + }), ).to.be.revertedWithCustomError(kycFacet, "InvalidKycStatus"); }); }); @@ -587,14 +578,11 @@ describe("ProtectedPartitions Tests", () => { await pauseFacet.connect(signer_B).pause(); await expect( - erc1410Facet.protectedRedeemFromByPartition( - DEFAULT_PARTITION, - signer_A.address, - amount, - MAX_UINT256, - 1, - "0x1234", - ), + erc1410Facet.protectedRedeemFromByPartition(DEFAULT_PARTITION, signer_A.address, amount, { + deadline: MAX_UINT256, + nounce: 1, + signature: "0x1234", + }), ).to.be.rejectedWith("TokenIsPaused"); }); @@ -604,14 +592,11 @@ describe("ProtectedPartitions Tests", () => { await clearingFacet.activateClearing(); await expect( - erc1410Facet.protectedRedeemFromByPartition( - DEFAULT_PARTITION, - signer_A.address, - amount, - MAX_UINT256, - 1, - "0x1234", - ), + erc1410Facet.protectedRedeemFromByPartition(DEFAULT_PARTITION, signer_A.address, amount, { + deadline: MAX_UINT256, + nounce: 1, + signature: "0x1234", + }), ).to.be.revertedWithCustomError(clearingFacet, "ClearingIsActivated"); }); @@ -619,14 +604,11 @@ describe("ProtectedPartitions Tests", () => { await setProtected(); await expect( - erc1410Facet.protectedRedeemFromByPartition( - DEFAULT_PARTITION, - signer_A.address, - amount, - MAX_UINT256, - 1, - "0x1234", - ), + erc1410Facet.protectedRedeemFromByPartition(DEFAULT_PARTITION, signer_A.address, amount, { + deadline: MAX_UINT256, + nounce: 1, + signature: "0x1234", + }), ).to.be.rejectedWith("AccountHasNoRole"); }); @@ -636,9 +618,11 @@ describe("ProtectedPartitions Tests", () => { await controlListFacet.connect(signer_B).addToControlList(signer_A.address); await expect( - erc1410Facet - .connect(signer_B) - .protectedRedeemFromByPartition(DEFAULT_PARTITION, signer_A.address, amount, MAX_UINT256, 1, "0x1234"), + erc1410Facet.connect(signer_B).protectedRedeemFromByPartition(DEFAULT_PARTITION, signer_A.address, amount, { + deadline: MAX_UINT256, + nounce: 1, + signature: "0x1234", + }), ).to.be.rejectedWith("AccountIsBlocked"); }); @@ -647,9 +631,11 @@ describe("ProtectedPartitions Tests", () => { await kycFacet.connect(signer_B).revokeKyc(signer_A.address); await expect( - erc1410Facet - .connect(signer_B) - .protectedRedeemFromByPartition(DEFAULT_PARTITION, signer_A.address, amount, MAX_UINT256, 1, "0x1234"), + erc1410Facet.connect(signer_B).protectedRedeemFromByPartition(DEFAULT_PARTITION, signer_A.address, amount, { + deadline: MAX_UINT256, + nounce: 1, + signature: "0x1234", + }), ).to.be.revertedWithCustomError(kycFacet, "InvalidKycStatus"); }); }); @@ -760,23 +746,21 @@ describe("ProtectedPartitions Tests", () => { await expect( erc1410Facet .connect(signer_B) - .protectedTransferFromByPartition( - DEFAULT_PARTITION, - signer_A.address, - signer_B.address, - amount, - 1, - 0, - "0x1234", - ), + .protectedTransferFromByPartition(DEFAULT_PARTITION, signer_A.address, signer_B.address, amount, { + deadline: 1, + nounce: 0, + signature: "0x1234", + }), ).to.be.rejectedWith("PartitionsAreUnProtected"); }); it("GIVEN an unprotected partitions equity WHEN performing a protected redeem THEN transaction fails with PartitionsAreUnProtected", async () => { await expect( - erc1410Facet - .connect(signer_B) - .protectedRedeemFromByPartition(DEFAULT_PARTITION, signer_A.address, amount, 1, 0, "0x1234"), + erc1410Facet.connect(signer_B).protectedRedeemFromByPartition(DEFAULT_PARTITION, signer_A.address, amount, { + deadline: 1, + nounce: 0, + signature: "0x1234", + }), ).to.be.rejectedWith("PartitionsAreUnProtected"); }); @@ -870,15 +854,11 @@ describe("ProtectedPartitions Tests", () => { await expect( erc1410Facet .connect(signer_B) - .protectedTransferFromByPartition( - DEFAULT_PARTITION, - signer_A.address, - signer_B.address, - amount, - 1, - 1, - "0x1234", - ), + .protectedTransferFromByPartition(DEFAULT_PARTITION, signer_A.address, signer_B.address, amount, { + deadline: 1, + nounce: 1, + signature: "0x1234", + }), ).to.be.rejectedWith("ExpiredDeadline"); }); @@ -892,15 +872,11 @@ describe("ProtectedPartitions Tests", () => { await expect( erc1410Facet .connect(signer_B) - .protectedTransferFromByPartition( - DEFAULT_PARTITION, - signer_A.address, - signer_B.address, - amount, - MAX_UINT256, - 1, - "0x01", - ), + .protectedTransferFromByPartition(DEFAULT_PARTITION, signer_A.address, signer_B.address, amount, { + deadline: MAX_UINT256, + nounce: 1, + signature: "0x01", + }), ).to.be.rejectedWith("WrongSignatureLength"); }); @@ -914,15 +890,12 @@ describe("ProtectedPartitions Tests", () => { await expect( erc1410Facet .connect(signer_B) - .protectedTransferFromByPartition( - DEFAULT_PARTITION, - signer_A.address, - signer_B.address, - amount, - MAX_UINT256, - 1, - "0x0011223344112233441122334411223344112233441122334411223344112233441122334411223344112233441122334411223344112233441122334411223344", - ), + .protectedTransferFromByPartition(DEFAULT_PARTITION, signer_A.address, signer_B.address, amount, { + deadline: MAX_UINT256, + nounce: 1, + signature: + "0x0011223344112233441122334411223344112233441122334411223344112233441122334411223344112233441122334411223344112233441122334411223344", + }), ).to.be.rejectedWith("WrongSignature"); }); @@ -938,15 +911,11 @@ describe("ProtectedPartitions Tests", () => { await expect( erc1410Facet .connect(signer_B) - .protectedTransferFromByPartition( - DEFAULT_PARTITION, - signer_A.address, - signer_B.address, - amount, - deadline, - 0, - "0x1234", - ), + .protectedTransferFromByPartition(DEFAULT_PARTITION, signer_A.address, signer_B.address, amount, { + deadline: deadline, + nounce: 0, + signature: "0x1234", + }), ).to.be.rejectedWith("WrongNounce"); }); @@ -1040,15 +1009,11 @@ describe("ProtectedPartitions Tests", () => { await erc1410Facet .connect(signer_B) - .protectedTransferFromByPartition( - DEFAULT_PARTITION, - signer_A.address, - signer_B.address, - amount, - deadline, - 1, - signature, - ); + .protectedTransferFromByPartition(DEFAULT_PARTITION, signer_A.address, signer_B.address, amount, { + deadline: deadline, + nounce: 1, + signature: signature, + }); }); }); @@ -1087,9 +1052,11 @@ describe("ProtectedPartitions Tests", () => { data: "0x", }); await expect( - erc1410Facet - .connect(signer_B) - .protectedRedeemFromByPartition(DEFAULT_PARTITION, signer_A.address, amount, 1, 0, "0x1234"), + erc1410Facet.connect(signer_B).protectedRedeemFromByPartition(DEFAULT_PARTITION, signer_A.address, amount, { + deadline: 1, + nounce: 0, + signature: "0x1234", + }), ).to.be.rejectedWith("ExpiredDeadline"); }); @@ -1101,9 +1068,11 @@ describe("ProtectedPartitions Tests", () => { data: "0x", }); await expect( - erc1410Facet - .connect(signer_B) - .protectedRedeemFromByPartition(DEFAULT_PARTITION, signer_A.address, amount, MAX_UINT256, 1, "0x01"), + erc1410Facet.connect(signer_B).protectedRedeemFromByPartition(DEFAULT_PARTITION, signer_A.address, amount, { + deadline: MAX_UINT256, + nounce: 1, + signature: "0x01", + }), ).to.be.rejectedWith("WrongSignatureLength"); }); @@ -1115,16 +1084,12 @@ describe("ProtectedPartitions Tests", () => { data: "0x", }); await expect( - erc1410Facet - .connect(signer_B) - .protectedRedeemFromByPartition( - DEFAULT_PARTITION, - signer_A.address, - amount, - MAX_UINT256, - 1, + erc1410Facet.connect(signer_B).protectedRedeemFromByPartition(DEFAULT_PARTITION, signer_A.address, amount, { + deadline: MAX_UINT256, + nounce: 1, + signature: "0x0011223344112233441122334411223344112233441122334411223344112233441122334411223344112233441122334411223344112233441122334411223344", - ), + }), ).to.be.rejectedWith("WrongSignature"); }); @@ -1138,9 +1103,11 @@ describe("ProtectedPartitions Tests", () => { const deadline = MAX_UINT256; await expect( - erc1410Facet - .connect(signer_B) - .protectedRedeemFromByPartition(DEFAULT_PARTITION, signer_A.address, amount, deadline, 0, "0x1234"), + erc1410Facet.connect(signer_B).protectedRedeemFromByPartition(DEFAULT_PARTITION, signer_A.address, amount, { + deadline: deadline, + nounce: 0, + signature: "0x1234", + }), ).to.be.rejectedWith("WrongNounce"); }); @@ -1175,7 +1142,11 @@ describe("ProtectedPartitions Tests", () => { await erc1410Facet .connect(signer_B) - .protectedRedeemFromByPartition(DEFAULT_PARTITION, signer_A.address, amount, deadline, 1, signature); + .protectedRedeemFromByPartition(DEFAULT_PARTITION, signer_A.address, amount, { + deadline: deadline, + nounce: 1, + signature: signature, + }); }); }); @@ -1523,15 +1494,11 @@ describe("ProtectedPartitions Tests", () => { await erc1410Facet .connect(signer_B) - .protectedTransferFromByPartition( - DEFAULT_PARTITION, - signer_A.address, - signer_B.address, - amount, - deadline, - 1, - signature, - ); + .protectedTransferFromByPartition(DEFAULT_PARTITION, signer_A.address, signer_B.address, amount, { + deadline: deadline, + nounce: 1, + signature: signature, + }); expect(await complianceMock.transferredHit()).to.equal(1); }); }); diff --git a/packages/ats/sdk/__tests__/fixtures/corporateActions/CorporateActionsFixture.ts b/packages/ats/sdk/__tests__/fixtures/corporateActions/CorporateActionsFixture.ts new file mode 100644 index 000000000..217ac3cdd --- /dev/null +++ b/packages/ats/sdk/__tests__/fixtures/corporateActions/CorporateActionsFixture.ts @@ -0,0 +1,220 @@ +/* + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +*/ + +import { HederaIdPropsFixture } from "../shared/DataFixture"; +import { createFixture } from "../config"; + +import { ActionContentHashExistsQuery } from "@query/security/actionContentHashExists/ActionContentHashExistsQuery"; +import ActionContentHashExistsRequest from "@port/in/request/security/operations/corporateActions/ActionContentHashExistsRequest"; + +export const ActionContentHashExistsQueryFixture = createFixture((query) => { + query.securityId.as(() => HederaIdPropsFixture.create().value); + query.contentHash.faker((faker) => `0x${faker.string.hexadecimal({ length: 64, prefix: "" })}`); +}); + +export const ActionContentHashExistsRequestFixture = createFixture((request) => { + request.securityId.as(() => HederaIdPropsFixture.create().value); + request.contentHash.faker((faker) => `0x${faker.string.hexadecimal({ length: 64, prefix: "" })}`); +}); diff --git a/packages/ats/sdk/src/app/usecase/query/security/actionContentHashExists/ActionContentHashExistsQuery.ts b/packages/ats/sdk/src/app/usecase/query/security/actionContentHashExists/ActionContentHashExistsQuery.ts new file mode 100644 index 000000000..8e11cd6ff --- /dev/null +++ b/packages/ats/sdk/src/app/usecase/query/security/actionContentHashExists/ActionContentHashExistsQuery.ts @@ -0,0 +1,220 @@ +/* + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +*/ + +import { Query } from "@core/query/Query"; +import { QueryResponse } from "@core/query/QueryResponse"; + +export class ActionContentHashExistsQueryResponse implements QueryResponse { + constructor(public readonly payload: boolean) {} +} + +export class ActionContentHashExistsQuery extends Query { + constructor( + public readonly securityId: string, + public readonly contentHash: string, + ) { + super(); + } +} diff --git a/packages/ats/sdk/src/app/usecase/query/security/actionContentHashExists/ActionContentHashExistsQueryHandler.ts b/packages/ats/sdk/src/app/usecase/query/security/actionContentHashExists/ActionContentHashExistsQueryHandler.ts new file mode 100644 index 000000000..153419135 --- /dev/null +++ b/packages/ats/sdk/src/app/usecase/query/security/actionContentHashExists/ActionContentHashExistsQueryHandler.ts @@ -0,0 +1,237 @@ +/* + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +*/ + +import { ActionContentHashExistsQuery, ActionContentHashExistsQueryResponse } from "./ActionContentHashExistsQuery"; +import { QueryHandler } from "@core/decorator/QueryHandlerDecorator"; +import { IQueryHandler } from "@core/query/QueryHandler"; +import { RPCQueryAdapter } from "@port/out/rpc/RPCQueryAdapter"; +import { lazyInject } from "@core/decorator/LazyInjectDecorator"; +import EvmAddress from "@domain/context/contract/EvmAddress"; +import ContractService from "@service/contract/ContractService"; +import { ActionContentHashExistsQueryError } from "./error/ActionContentHashExistsQueryError"; + +@QueryHandler(ActionContentHashExistsQuery) +export class ActionContentHashExistsQueryHandler implements IQueryHandler { + constructor( + @lazyInject(RPCQueryAdapter) + private readonly queryAdapter: RPCQueryAdapter, + @lazyInject(ContractService) + private readonly contractService: ContractService, + ) {} + + async execute(query: ActionContentHashExistsQuery): Promise { + try { + const { securityId, contentHash } = query; + + const securityEvmAddress: EvmAddress = await this.contractService.getContractEvmAddress(securityId); + + const res = await this.queryAdapter.actionContentHashExists(securityEvmAddress, contentHash); + + return new ActionContentHashExistsQueryResponse(res); + } catch (error) { + throw new ActionContentHashExistsQueryError(error as Error); + } + } +} diff --git a/packages/ats/sdk/src/app/usecase/query/security/actionContentHashExists/ActionContentHashExistsQueryHandler.unit.test.ts b/packages/ats/sdk/src/app/usecase/query/security/actionContentHashExists/ActionContentHashExistsQueryHandler.unit.test.ts new file mode 100644 index 000000000..3a8b99919 --- /dev/null +++ b/packages/ats/sdk/src/app/usecase/query/security/actionContentHashExists/ActionContentHashExistsQueryHandler.unit.test.ts @@ -0,0 +1,268 @@ +/* + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +*/ + +import { createMock } from "@golevelup/ts-jest"; +import { ErrorMsgFixture, EvmAddressPropsFixture } from "@test/fixtures/shared/DataFixture"; +import { ErrorCode } from "@core/error/BaseError"; +import { RPCQueryAdapter } from "@port/out/rpc/RPCQueryAdapter"; +import EvmAddress from "@domain/context/contract/EvmAddress"; +import ContractService from "@service/contract/ContractService"; +import { ActionContentHashExistsQueryFixture } from "@test/fixtures/corporateActions/CorporateActionsFixture"; +import { ActionContentHashExistsQuery, ActionContentHashExistsQueryResponse } from "./ActionContentHashExistsQuery"; +import { ActionContentHashExistsQueryHandler } from "./ActionContentHashExistsQueryHandler"; +import { ActionContentHashExistsQueryError } from "./error/ActionContentHashExistsQueryError"; + +describe("ActionContentHashExistsQueryHandler", () => { + let handler: ActionContentHashExistsQueryHandler; + let query: ActionContentHashExistsQuery; + + const queryAdapterServiceMock = createMock(); + const contractServiceMock = createMock(); + + const evmAddress = new EvmAddress(EvmAddressPropsFixture.create().value); + const errorMsg = ErrorMsgFixture.create().msg; + + beforeEach(() => { + handler = new ActionContentHashExistsQueryHandler(queryAdapterServiceMock, contractServiceMock); + query = ActionContentHashExistsQueryFixture.create(); + }); + + afterEach(() => { + jest.resetAllMocks(); + }); + + describe("execute", () => { + it("throws ActionContentHashExistsQueryError when query fails with uncaught error", async () => { + const fakeError = new Error(errorMsg); + + contractServiceMock.getContractEvmAddress.mockRejectedValue(fakeError); + + const resultPromise = handler.execute(query); + + await expect(resultPromise).rejects.toBeInstanceOf(ActionContentHashExistsQueryError); + + await expect(resultPromise).rejects.toMatchObject({ + message: expect.stringContaining( + `An error occurred while querying action content hash exists: ${errorMsg}`, + ), + errorCode: ErrorCode.UncaughtQueryError, + }); + }); + + it("should successfully check action content hash exist", async () => { + contractServiceMock.getContractEvmAddress.mockResolvedValueOnce(evmAddress); + + queryAdapterServiceMock.actionContentHashExists.mockResolvedValueOnce(true); + + const result = await handler.execute(query); + + expect(result).toBeInstanceOf(ActionContentHashExistsQueryResponse); + expect(result.payload).toBe(true); + expect(contractServiceMock.getContractEvmAddress).toHaveBeenCalledTimes(1); + expect(contractServiceMock.getContractEvmAddress).toHaveBeenCalledWith(query.securityId); + expect(queryAdapterServiceMock.actionContentHashExists).toHaveBeenCalledWith(evmAddress, query.contentHash); + }); + }); +}); diff --git a/packages/ats/sdk/src/app/usecase/query/security/actionContentHashExists/error/ActionContentHashExistsQueryError.ts b/packages/ats/sdk/src/app/usecase/query/security/actionContentHashExists/error/ActionContentHashExistsQueryError.ts new file mode 100644 index 000000000..3a06ac4dc --- /dev/null +++ b/packages/ats/sdk/src/app/usecase/query/security/actionContentHashExists/error/ActionContentHashExistsQueryError.ts @@ -0,0 +1,214 @@ +/* + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +*/ + +import { QueryError } from "@query/error/QueryError"; +import BaseError from "@core/error/BaseError"; + +export class ActionContentHashExistsQueryError extends QueryError { + constructor(error: Error) { + const msg = `An error occurred while querying action content hash exists: ${error.message}`; + super(msg, error instanceof BaseError ? error.errorCode : undefined); + } +} diff --git a/packages/ats/sdk/src/core/injectable/kyc/InjectableKyc.ts b/packages/ats/sdk/src/core/injectable/kyc/InjectableKyc.ts index b59f04a07..3bfd10549 100644 --- a/packages/ats/sdk/src/core/injectable/kyc/InjectableKyc.ts +++ b/packages/ats/sdk/src/core/injectable/kyc/InjectableKyc.ts @@ -203,34 +203,35 @@ */ -import { UpdateExternalKycListsCommandHandler } from '@command/security/externalKycLists/updateExternalKycLists/UpdateExternalKycListsCommandHandler'; -import { TOKENS } from '../Tokens'; -import { AddExternalKycListCommandHandler } from '@command/security/externalKycLists/addExternalKycList/AddExternalKycListCommandHandler'; -import { RemoveExternalKycListCommandHandler } from '@command/security/externalKycLists/removeExternalKycList/RemoveExternalKycListCommandHandler'; -import { ActivateInternalKycCommandHandler } from '@command/security/kyc/activateInternalKyc/ActivateInternalKycCommandHandler'; -import { DeactivateInternalKycCommandHandler } from '@command/security/kyc/deactivateInternalKyc/DeactivateInternalKycCommandHandler'; -import { GrantKycCommandHandler } from '@command/security/kyc/grantKyc/GrantKycCommandHandler'; -import { RevokeKycCommandHandler } from '@command/security/kyc/revokeKyc/RevokeKycCommandHandler'; -import { GrantKycMockCommandHandler } from '@command/security/externalKycLists/mock/grantKycMock/GrantKycMockCommandHandler'; -import { RevokeKycMockCommandHandler } from '@command/security/externalKycLists/mock/revokeKycMock/RevokeKycMockCommandHandler'; -import { CreateExternalKycListMockCommandHandler } from '@command/security/externalKycLists/mock/createExternalKycMock/CreateExternalKycMockCommandHandler'; -import { GetKycStatusMockQueryHandler } from '@query/security/externalKycLists/mock/getKycStatusMock/GetKycStatusMockQueryHandler'; -import { GetKycForQueryHandler } from '@query/security/kyc/getKycFor/GetKycForQueryHandler'; -import { GetKycAccountsCountQueryHandler } from '@query/security/kyc/getKycAccountsCount/GetKycAccountsCountQueryHandler'; -import { GetKycAccountsDataQueryHandler } from '@query/security/kyc/getKycAccountsData/GetKycAccountsDataQueryHandler'; -import { GetKycStatusForQueryHandler } from '@query/security/kyc/getKycStatusFor/GetKycStatusForQueryHandler'; -import { GetIssuerListCountQueryHandler } from '@query/security/ssi/getIssuerListCount/GetIssuerListCountQueryHandler'; -import { GetIssuerListMembersQueryHandler } from '@query/security/ssi/getIssuerListMembers/GetIssuerListMembersQueryHandler'; -import { GetRevocationRegistryAddressQueryHandler } from '@query/security/ssi/getRevocationRegistryAddress/GetRevocationRegistryAddressQueryHandler'; -import { IsIssuerQueryHandler } from '@query/security/ssi/isIssuer/IsIssuerQueryHandler'; -import { GetExternalKycListsCountQueryHandler } from '@query/security/externalKycLists/getExternalKycListsCount/GetExternalKycListsCountQueryHandler'; -import { GetExternalKycListsMembersQueryHandler } from '@query/security/externalKycLists/getExternalKycListsMembers/GetExternalKycListsMembersQueryHandler'; -import { IsExternalKycListQueryHandler } from '@query/security/externalKycLists/isExternalKycList/IsExternalKycListQueryHandler'; -import { IsExternallyGrantedQueryHandler } from '@query/security/externalKycLists/isExternallyGranted/IsExternallyGrantedQueryHandler'; -import { IsInternalKycActivatedQueryHandler } from '@query/security/kyc/isInternalKycActivated/IsInternalKycActivatedQueryHandler'; -import { AddIssuerCommandHandler } from '@command/security/ssi/addIssuer/AddIssuerCommandHandler'; -import { RemoveIssuerCommandHandler } from '@command/security/ssi/removeIssuer/RemoveIssuerCommandHandler'; -import { SetRevocationRegistryAddressCommandHandler } from '@command/security/ssi/setRevocationRegistryAddress/SetRevocationRegistryAddressCommandHandler'; +import { UpdateExternalKycListsCommandHandler } from "@command/security/externalKycLists/updateExternalKycLists/UpdateExternalKycListsCommandHandler"; +import { TOKENS } from "../Tokens"; +import { AddExternalKycListCommandHandler } from "@command/security/externalKycLists/addExternalKycList/AddExternalKycListCommandHandler"; +import { RemoveExternalKycListCommandHandler } from "@command/security/externalKycLists/removeExternalKycList/RemoveExternalKycListCommandHandler"; +import { ActivateInternalKycCommandHandler } from "@command/security/kyc/activateInternalKyc/ActivateInternalKycCommandHandler"; +import { DeactivateInternalKycCommandHandler } from "@command/security/kyc/deactivateInternalKyc/DeactivateInternalKycCommandHandler"; +import { GrantKycCommandHandler } from "@command/security/kyc/grantKyc/GrantKycCommandHandler"; +import { RevokeKycCommandHandler } from "@command/security/kyc/revokeKyc/RevokeKycCommandHandler"; +import { GrantKycMockCommandHandler } from "@command/security/externalKycLists/mock/grantKycMock/GrantKycMockCommandHandler"; +import { RevokeKycMockCommandHandler } from "@command/security/externalKycLists/mock/revokeKycMock/RevokeKycMockCommandHandler"; +import { CreateExternalKycListMockCommandHandler } from "@command/security/externalKycLists/mock/createExternalKycMock/CreateExternalKycMockCommandHandler"; +import { GetKycStatusMockQueryHandler } from "@query/security/externalKycLists/mock/getKycStatusMock/GetKycStatusMockQueryHandler"; +import { GetKycForQueryHandler } from "@query/security/kyc/getKycFor/GetKycForQueryHandler"; +import { GetKycAccountsCountQueryHandler } from "@query/security/kyc/getKycAccountsCount/GetKycAccountsCountQueryHandler"; +import { GetKycAccountsDataQueryHandler } from "@query/security/kyc/getKycAccountsData/GetKycAccountsDataQueryHandler"; +import { GetKycStatusForQueryHandler } from "@query/security/kyc/getKycStatusFor/GetKycStatusForQueryHandler"; +import { GetIssuerListCountQueryHandler } from "@query/security/ssi/getIssuerListCount/GetIssuerListCountQueryHandler"; +import { GetIssuerListMembersQueryHandler } from "@query/security/ssi/getIssuerListMembers/GetIssuerListMembersQueryHandler"; +import { GetRevocationRegistryAddressQueryHandler } from "@query/security/ssi/getRevocationRegistryAddress/GetRevocationRegistryAddressQueryHandler"; +import { IsIssuerQueryHandler } from "@query/security/ssi/isIssuer/IsIssuerQueryHandler"; +import { GetExternalKycListsCountQueryHandler } from "@query/security/externalKycLists/getExternalKycListsCount/GetExternalKycListsCountQueryHandler"; +import { GetExternalKycListsMembersQueryHandler } from "@query/security/externalKycLists/getExternalKycListsMembers/GetExternalKycListsMembersQueryHandler"; +import { IsExternalKycListQueryHandler } from "@query/security/externalKycLists/isExternalKycList/IsExternalKycListQueryHandler"; +import { IsExternallyGrantedQueryHandler } from "@query/security/externalKycLists/isExternallyGranted/IsExternallyGrantedQueryHandler"; +import { IsInternalKycActivatedQueryHandler } from "@query/security/kyc/isInternalKycActivated/IsInternalKycActivatedQueryHandler"; +import { AddIssuerCommandHandler } from "@command/security/ssi/addIssuer/AddIssuerCommandHandler"; +import { RemoveIssuerCommandHandler } from "@command/security/ssi/removeIssuer/RemoveIssuerCommandHandler"; +import { SetRevocationRegistryAddressCommandHandler } from "@command/security/ssi/setRevocationRegistryAddress/SetRevocationRegistryAddressCommandHandler"; +import { ActionContentHashExistsQueryHandler } from "@query/security/actionContentHashExists/ActionContentHashExistsQueryHandler"; export const COMMAND_HANDLERS_KYC = [ { @@ -344,4 +345,8 @@ export const QUERY_HANDLERS_KYC = [ token: TOKENS.QUERY_HANDLER, useClass: IsInternalKycActivatedQueryHandler, }, + { + token: TOKENS.QUERY_HANDLER, + useClass: ActionContentHashExistsQueryHandler, + }, ]; diff --git a/packages/ats/sdk/src/domain/context/factory/ProtectionData.ts b/packages/ats/sdk/src/domain/context/factory/ProtectionData.ts new file mode 100644 index 000000000..7fc1b1179 --- /dev/null +++ b/packages/ats/sdk/src/domain/context/factory/ProtectionData.ts @@ -0,0 +1,211 @@ +/* + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +*/ +import { BigNumber } from "ethers"; + +export class ProtectionData { + public deadline: BigNumber; + public nounce: BigNumber; + public signature: string; +} diff --git a/packages/ats/sdk/src/port/in/request/index.ts b/packages/ats/sdk/src/port/in/request/index.ts index e3916c572..2f5adce5d 100644 --- a/packages/ats/sdk/src/port/in/request/index.ts +++ b/packages/ats/sdk/src/port/in/request/index.ts @@ -203,204 +203,205 @@ */ -import IssueRequest from './security/operations/issue/IssueRequest'; -import RedeemRequest from './security/operations/redeem/RedeemRequest'; -import ForceRedeemRequest from './security/operations/redeem/ForceRedeemRequest'; -import CreateEquityRequest from './equity/CreateEquityRequest'; -import CreateBondRequest from './bond/CreateBondRequest'; -import RoleRequest from './security/roles/RoleRequest'; -import ApplyRolesRequest from './security/roles/ApplyRolesRequest'; -import ValidationResponse from '@core/validation/ValidationResponse'; -import TransferRequest from './security/operations/transfer/TransferRequest'; -import TransferAndLockRequest from './security/operations/transfer/TransferAndLockRequest'; -import ForceTransferRequest from './security/operations/transfer/ForceTransferRequest'; -import GetAccountBalanceRequest from './account/GetAccountBalanceRequest'; -import GetAccountInfoRequest from './account/GetAccountInfoRequest'; -import PauseRequest from './security/operations/pause/PauseRequest'; -import ControlListRequest from './security/operations/controlList/ControlListRequest'; -import GetControlListCountRequest from './security/operations/controlList/GetControlListCountRequest'; -import GetControlListMembersRequest from './security/operations/controlList/GetControlListMembersRequest'; -import GetDividendsForRequest from './equity/GetDividendsForRequest'; -import GetDividendsRequest from './equity/GetDividendsRequest'; -import GetAllDividendsRequest from './equity/GetAllDividendsRequest'; -import GetVotingRightsForRequest from './equity/GetVotingRightsForRequest'; -import GetVotingRightsRequest from './equity/GetVotingRightsRequest'; -import GetAllVotingRightsRequest from './equity/GetAllVotingRightsRequest'; -import GetCouponForRequest from './bond/GetCouponForRequest'; -import GetCouponRequest from './bond/GetCouponRequest'; -import GetAllCouponsRequest from './bond/GetAllCouponsRequest'; -import GetRoleCountForRequest from './security/roles/GetRoleCountForRequest'; -import GetRolesForRequest from './security/roles/GetRolesForRequest'; -import GetRoleMemberCountRequest from './security/roles/GetRoleMemberCountRequest'; -import GetRoleMembersRequest from './security/roles/GetRoleMembersRequest'; -import GetSecurityDetailsRequest from './security/GetSecurityDetailsRequest'; -import SetDividendsRequest from './equity/SetDividendsRequest'; -import SetCouponRequest from './bond/SetCouponRequest'; -import SetVotingRightsRequest from './equity/SetVotingRightsRequest'; -import GetBondDetailsRequest from './bond/GetBondDetailsRequest'; -import GetEquityDetailsRequest from './equity/GetEquityDetailsRequest'; -import SetMaxSupplyRequest from './security/operations/cap/SetMaxSupplyRequest'; -import GetMaxSupplyRequest from './security/operations/cap/GetMaxSupplyRequest'; -import GetRegulationDetailsRequest from './factory/GetRegulationDetailsRequest'; -import GetLockedBalanceRequest from './security/operations/lock/GetLockedBalanceRequest'; -import LockRequest from './security/operations/lock/LockRequest'; -import ReleaseRequest from './security/operations/release/ReleaseRequest'; -import GetLockCountRequest from './security/operations/lock/GetLockCountRequest'; -import GetLocksIdRequest from './security/operations/lock/GetLocksIdRequest'; -import GetLockRequest from './security/operations/lock/GetLockRequest'; -import ExecuteHoldByPartitionRequest from './security/operations/hold/ExecuteHoldByPartitionRequest'; - -import GetControlListTypeRequest from './security/operations/controlList/GetControlListTypeRequest'; -import InitializationRequest from './network/InitializationRequest'; -import ConnectRequest from './network/ConnectRequest'; -import GetConfigInfoRequest from './management/GetConfigInfoRequest'; -import UpdateConfigRequest from './management/UpdateConfigRequest'; -import UpdateConfigVersionRequest from './management/UpdateConfigVersionRequest'; -import UpdateResolverRequest from './management/UpdateResolverRequest'; -import UpdateMaturityDateRequest from './bond/UpdateMaturityDateRequest'; -import SetScheduledBalanceAdjustmentRequest from './equity/SetScheduledBalanceAdjustmentRequest'; -import GetScheduledBalanceAdjustmentRequest from './equity/GetScheduledBalanceAdjustmentRequest'; -import GetScheduledBalanceAdjustmentCountRequest from './equity/GetScheduledBalanceAdjustmentsCountRequest'; -import GetAllScheduledBalanceAdjustmentsRequest from './equity/GetAllScheduledBalanceAdjustmentst'; -import GetLastAggregatedBalanceAdjustmentFactorForRequest from './equity/GetLastAggregatedBalanceAdjustmentFactorForRequest'; -import GetAggregatedBalanceAdjustmentFactorRequest from './account/GetAggregatedBalanceAdjustmentFactorRequest'; -import GetLastAggregatedBalanceAdjustmentFactorForByPartitionRequest from './equity/GetLastAggregatedBalanceAdjustmentFactorForByPartitionRequest'; -import ProtectedTransferFromByPartitionRequest from './security/operations/transfer/ProtectedTransferFromByPartitionRequest'; -import ProtectedRedeemFromByPartitionRequest from './security/operations/redeem/ProtectedRedeemFromByPartitionRequest'; -import GetNounceRequest from './security/operations/protectedPartitions/GetNounceRequest'; -import PartitionsProtectedRequest from './security/operations/protectedPartitions/PartitionsProtectedRequest'; -import ProtectedTransferAndLockByPartitionRequest from './security/operations/transfer/ProtectedTransferAndLockByPartitionRequest'; -import CreateHoldByPartitionRequest from './security/operations/hold/CreateHoldByPartition'; -import CreateHoldFromByPartitionRequest from './security/operations/hold/CreateHoldFromByPartition'; -import ControllerCreateHoldByPartitionRequest from './security/operations/hold/ControllerCreateHoldFromByPartition'; -import ProtectedCreateHoldByPartitionRequest from './security/operations/hold/ProtectedCreateHoldFromByPartition'; -import GetHeldAmountForRequest from './security/operations/hold/GetHeldAmountForRequest'; -import GetHeldAmountForByPartitionRequest from './security/operations/hold/GetHeldAmountForByPartitionRequest'; -import GetHoldCountForByPartitionRequest from './security/operations/hold/GetHoldCountForByPartitionRequest'; -import GetHoldsIdForByPartitionRequest from './security/operations/hold/GetHoldsIdForByPartitionRequest'; -import GetHoldForByPartitionRequest from './security/operations/hold/GetHoldForByPartitionRequest'; -import ReleaseHoldByPartitionRequest from './security/operations/release/ReleaseHoldByPartitionRequest'; -import ReclaimHoldByPartitionRequest from './security/operations/hold/ReclaimHoldByPartitionRequest'; -import AddIssuerRequest from './security/ssi/AddIssuerRequest'; -import SetRevocationRegistryAddressRequest from './security/ssi/SetRevocationRegistryAddressRequest'; -import RemoveIssuerRequest from './security/operations/issue/RemoveIssuerRequest'; -import GetRevocationRegistryAddressRequest from './security/ssi/GetRevocationRegistryAddressRequest'; -import GetIssuerListCountRequest from './security/ssi/GetIssuerListCountRequest'; -import GetIssuerListMembersRequest from './security/ssi/GetIssuerListMembersRequest'; -import IsIssuerRequest from './security/operations/issue/IsIssuerRequest'; -import GetKycAccountsCountRequest from './security/kyc/GetKycAccountsCountRequest'; -import GetKycForRequest from './security/kyc/GetKycForRequest'; -import RevokeKycRequest from './security/kyc/RevokeKycRequest'; -import GrantKycRequest from './security/kyc/GrantKycRequest'; -import GetKycAccountsDataRequest from './security/kyc/GetKycAccountsDataRequest'; -import GetKycStatusForRequest from './security/kyc/GetKycStatusForRequest'; -import ActivateClearingRequest from './security/operations/clearing/ActivateClearingRequest'; -import DeactivateClearingRequest from './security/operations/clearing/DeactivateClearingRequest'; -import ClearingTransferByPartitionRequest from './security/operations/clearing/ClearingTransferByPartitionRequest'; -import ClearingTransferFromByPartitionRequest from './security/operations/clearing/ClearingTransferFromByPartitionRequest'; -import ProtectedClearingTransferByPartitionRequest from './security/operations/clearing/ProtectedClearingTransferByPartitionRequest'; -import ApproveClearingOperationByPartitionRequest from './security/operations/clearing/ApproveClearingOperationByPartitionRequest'; -import CancelClearingOperationByPartitionRequest from './security/operations/clearing/CancelClearingOperationByPartitionRequest'; -import ReclaimClearingOperationByPartitionRequest from './security/operations/clearing/ReclaimClearingOperationByPartitionRequest'; -import ClearingRedeemByPartitionRequest from './security/operations/clearing/ClearingRedeemByPartitionRequest'; -import ClearingRedeemFromByPartitionRequest from './security/operations/clearing/ClearingRedeemFromByPartitionRequest'; -import ProtectedClearingRedeemByPartitionRequest from './security/operations/clearing/ProtectedClearingRedeemByPartitionRequest'; -import ClearingCreateHoldByPartitionRequest from './security/operations/clearing/ClearingCreateHoldByPartitionRequest'; -import ClearingCreateHoldFromByPartitionRequest from './security/operations/clearing/ClearingCreateHoldFromByPartitionRequest'; -import ProtectedClearingCreateHoldByPartitionRequest from './security/operations/clearing/ProtectedClearingCreateHoldByPartitionRequest'; -import GetClearedAmountForByPartitionRequest from './security/operations/clearing/GetClearedAmountForByPartitionRequest'; -import GetClearedAmountForRequest from './security/operations/clearing/GetClearedAmountForRequest'; -import GetClearingCountForByPartitionRequest from './security/operations/clearing/GetClearingCountForByPartitionRequest'; -import GetClearingsIdForByPartitionRequest from './security/operations/clearing/GetClearingsIdForByPartitionRequest'; -import IsClearingActivatedRequest from './security/operations/clearing/IsClearingActivatedRequest'; -import OperatorClearingCreateHoldByPartitionRequest from './security/operations/clearing/OperatorClearingCreateHoldByPartitionRequest'; -import OperatorClearingRedeemByPartitionRequest from './security/operations/clearing/OperatorClearingRedeemByPartitionRequest'; -import OperatorClearingTransferByPartitionRequest from './security/operations/clearing/OperatorClearingTransferByPartitionRequest'; -import GetClearingCreateHoldForByPartitionRequest from './security/operations/clearing/GetClearingCreateHoldForByPartitionRequest'; -import GetClearingRedeemForByPartitionRequest from './security/operations/clearing/GetClearingRedeemForByPartitionRequest'; -import GetClearingTransferForByPartitionRequest from './security/operations/clearing/GetClearingTransferForByPartitionRequest'; -import UpdateExternalPausesRequest from './security/externalPauses/UpdateExternalPausesRequest'; -import AddExternalPauseRequest from './security/externalPauses/AddExternalPauseRequest'; -import RemoveExternalPauseRequest from './security/externalPauses/RemoveExternalPauseRequest'; -import IsExternalPauseRequest from './security/externalPauses/IsExternalPauseRequest'; -import GetExternalPausesCountRequest from './security/externalPauses/GetExternalPausesCountRequest'; -import GetExternalPausesMembersRequest from './security/externalPauses/GetExternalPausesMembersRequest'; -import IsPausedMockRequest from './security/externalPauses/mock/IsPausedMockRequest'; -import SetPausedMockRequest from './security/externalPauses/mock/SetPausedMockRequest'; -import UpdateExternalControlListsRequest from './security/externalControlLists/UpdateExternalControlListsRequest'; -import AddExternalControlListRequest from './security/externalControlLists/AddExternalControlListRequest'; -import RemoveExternalControlListRequest from './security/externalControlLists/RemoveExternalControlListRequest'; -import GetExternalControlListsCountRequest from './security/externalControlLists/GetExternalControlListsCountRequest'; -import IsExternalControlListRequest from './security/externalControlLists/IsExternalControlListRequest'; -import GetExternalControlListsMembersRequest from './security/externalControlLists/GetExternalControlListsMembersRequest'; -import AddToBlackListMockRequest from './security/externalControlLists/mock/AddToBlackListMockRequest'; -import AddToWhiteListMockRequest from './security/externalControlLists/mock/AddToWhiteListMockRequest'; -import RemoveFromBlackListMockRequest from './security/externalControlLists/mock/RemoveFromBlackListMockRequest'; -import RemoveFromWhiteListMockRequest from './security/externalControlLists/mock/RemoveFromWhiteListMockRequest'; -import IsAuthorizedBlackListMockRequest from './security/externalControlLists/mock/IsAuthorizedBlackListMockRequest'; -import IsAuthorizedWhiteListMockRequest from './security/externalControlLists/mock/IsAuthorizedWhiteListMockRequest'; -import UpdateExternalKycListsRequest from './security/externalKycLists/UpdateExternalKycListsRequest'; -import AddExternalKycListRequest from './security/externalKycLists/AddExternalKycListRequest'; -import RemoveExternalKycListRequest from './security/externalKycLists/RemoveExternalKycListRequest'; -import GetExternalKycListsCountRequest from './security/externalKycLists/GetExternalKycListsCountRequest'; -import GetExternalKycListsMembersRequest from './security/externalKycLists/GetExternalKycListsMembersRequest'; -import IsExternalKycListRequest from './security/externalKycLists/IsExternalKycListRequest'; -import IsExternallyGrantedRequest from './security/externalKycLists/IsExternallyGrantedRequest'; -import ActivateInternalKycRequest from './security/kyc/ActivateInternalKycRequest'; -import IsInternalKycActivatedRequest from './security/kyc/IsInternalKycActivatedRequest'; -import GrantKycMockRequest from './security/externalKycLists/mock/GrantKycMockRequest'; -import RevokeKycMockRequest from './security/externalKycLists/mock/RevokeKycMockRequest'; -import GetKycStatusMockRequest from './security/externalKycLists/mock/GetKycStatusMockRequest'; -import SetNameRequest from './security/operations/tokeMetadata/SetNameRequest'; -import SetSymbolRequest from './security/operations/tokeMetadata/SetSymbolRequest'; -import SetOnchainIDRequest from './security/operations/tokeMetadata/SetOnchainIDRequest'; -import SetComplianceRequest from './security/compliance/SetComplianceRequest'; -import ComplianceRequest from './security/compliance/ComplianceRequest'; -import SetIdentityRegistryRequest from './security/identityRegistry/SetIdentityRegistryRequest'; -import IdentityRegistryRequest from './security/identityRegistry/IdentityRegistryRequest'; -import OnchainIDRequest from './security/operations/tokeMetadata/OnchainIDRequest'; -import BurnRequest from './security/operations/burn/BurnRequest'; -import MintRequest from './security/operations/mint/MintRequest'; -import RecoveryAddressRequest from './security/operations/recovery/RecoveryAddressRequest'; -import IsAddressRecoveredRequest from './security/operations/recovery/IsAddressRecoveredRequest'; -import ForcedTransferRequest from './security/operations/transfer/ForcedTransferRequest'; -import FreezePartialTokensRequest from './security/operations/freeze/FreezePartialTokensRequest'; -import GetFrozenPartialTokensRequest from './security/operations/freeze/GetFrozenPartialTokensRequest'; -import UnfreezePartialTokensRequest from './security/operations/freeze/UnfreezePartialTokensRequest'; -import AddAgentRequest from './security/operations/agent/AddAgentRequest'; -import RemoveAgentRequest from './security/operations/agent/RemoveAgentRequest'; -import BatchBurnRequest from './security/operations/batch/BatchBurnRequest'; -import BatchForcedTransferRequest from './security/operations/batch/BatchForcedTransferRequest'; -import BatchFreezePartialTokensRequest from './security/operations/batch/BatchFreezePartialTokensRequest'; -import BatchMintRequest from './security/operations/batch/BatchMintRequest'; -import BatchSetAddressFrozenRequest from './security/operations/batch/BatchSetAddressFrozenRequest'; -import BatchTransferRequest from './security/operations/batch/BatchTransferRequest'; -import BatchUnfreezePartialTokensRequest from './security/operations/batch/BatchUnfreezePartialTokensRequest'; -import SetAddressFrozenRequest from './security/operations/freeze/SetAddressFrozenRequest'; -import DeactivateInternalKycRequest from './security/kyc/DeactivateInternalKycRequest'; -import TakeSnapshotRequest from './security/operations/snapshot/TakeSnapshotRequest'; -import RedeemAtMaturityByPartitionRequest from './bond/RedeemAtMaturityByPartitionRequest'; -import FullRedeemAtMaturityRequest from './bond/FullRedeemAtMaturityRequest'; -import GetTokenHoldersAtSnapshotRequest from './security/operations/snapshot/GetTokenHoldersAtSnapshotRequest'; -import GetTotalTokenHoldersAtSnapshotRequest from './security/operations/snapshot/GetTotalTokenHoldersAtSnapshotRequest'; -import GetCouponHoldersRequest from './bond/GetCouponHoldersRequest'; -import GetTotalCouponHoldersRequest from './bond/GetTotalCouponHoldersRequest'; -import GetDividendHoldersRequest from './equity/GetDividendHoldersRequest'; -import GetTotalDividendHoldersRequest from './equity/GetTotalDividendHoldersRequest'; -import GetTotalVotingHoldersRequest from './equity/GetTotalVotingHoldersRequest'; -import GetVotingHoldersRequest from './equity/GetVotingHoldersRequest'; -import GetSecurityHoldersRequest from './security/GetSecurityHoldersRequest'; -import GetTotalSecurityHoldersRequest from './security/GetTotalSecurityHoldersRequest'; -import CreateTrexSuiteEquityRequest from './equity/CreateTrexSuiteEquityRequest'; -import CreateTrexSuiteBondRequest from './bond/CreateTrexSuiteBondRequest'; -import AddProceedRecipientRequest from './bond/AddProceedRecipientRequest'; -import RemoveProceedRecipientRequest from './bond/RemoveProceedRecipientRequest'; -import UpdateProceedRecipientDataRequest from './bond/UpdateProceedRecipientDataRequest'; -import GetProceedRecipientDataRequest from './bond/GetProceedRecipientDataRequest'; -import GetProceedRecipientsCountRequest from './bond/GetProceedRecipientsCountRequest'; -import GetProceedRecipientsRequest from './bond/GetProceedRecipientsRequest'; -import IsProceedRecipientRequest from './bond/IsProceedRecipientRequest'; -import GetPrincipalForRequest from './bond/GetPrincipalForRequest'; +import IssueRequest from "./security/operations/issue/IssueRequest"; +import RedeemRequest from "./security/operations/redeem/RedeemRequest"; +import ForceRedeemRequest from "./security/operations/redeem/ForceRedeemRequest"; +import CreateEquityRequest from "./equity/CreateEquityRequest"; +import CreateBondRequest from "./bond/CreateBondRequest"; +import RoleRequest from "./security/roles/RoleRequest"; +import ApplyRolesRequest from "./security/roles/ApplyRolesRequest"; +import ValidationResponse from "@core/validation/ValidationResponse"; +import TransferRequest from "./security/operations/transfer/TransferRequest"; +import TransferAndLockRequest from "./security/operations/transfer/TransferAndLockRequest"; +import ForceTransferRequest from "./security/operations/transfer/ForceTransferRequest"; +import GetAccountBalanceRequest from "./account/GetAccountBalanceRequest"; +import GetAccountInfoRequest from "./account/GetAccountInfoRequest"; +import PauseRequest from "./security/operations/pause/PauseRequest"; +import ControlListRequest from "./security/operations/controlList/ControlListRequest"; +import GetControlListCountRequest from "./security/operations/controlList/GetControlListCountRequest"; +import GetControlListMembersRequest from "./security/operations/controlList/GetControlListMembersRequest"; +import GetDividendsForRequest from "./equity/GetDividendsForRequest"; +import GetDividendsRequest from "./equity/GetDividendsRequest"; +import GetAllDividendsRequest from "./equity/GetAllDividendsRequest"; +import GetVotingRightsForRequest from "./equity/GetVotingRightsForRequest"; +import GetVotingRightsRequest from "./equity/GetVotingRightsRequest"; +import GetAllVotingRightsRequest from "./equity/GetAllVotingRightsRequest"; +import GetCouponForRequest from "./bond/GetCouponForRequest"; +import GetCouponRequest from "./bond/GetCouponRequest"; +import GetAllCouponsRequest from "./bond/GetAllCouponsRequest"; +import GetRoleCountForRequest from "./security/roles/GetRoleCountForRequest"; +import GetRolesForRequest from "./security/roles/GetRolesForRequest"; +import GetRoleMemberCountRequest from "./security/roles/GetRoleMemberCountRequest"; +import GetRoleMembersRequest from "./security/roles/GetRoleMembersRequest"; +import GetSecurityDetailsRequest from "./security/GetSecurityDetailsRequest"; +import SetDividendsRequest from "./equity/SetDividendsRequest"; +import SetCouponRequest from "./bond/SetCouponRequest"; +import SetVotingRightsRequest from "./equity/SetVotingRightsRequest"; +import GetBondDetailsRequest from "./bond/GetBondDetailsRequest"; +import GetEquityDetailsRequest from "./equity/GetEquityDetailsRequest"; +import SetMaxSupplyRequest from "./security/operations/cap/SetMaxSupplyRequest"; +import GetMaxSupplyRequest from "./security/operations/cap/GetMaxSupplyRequest"; +import GetRegulationDetailsRequest from "./factory/GetRegulationDetailsRequest"; +import GetLockedBalanceRequest from "./security/operations/lock/GetLockedBalanceRequest"; +import LockRequest from "./security/operations/lock/LockRequest"; +import ReleaseRequest from "./security/operations/release/ReleaseRequest"; +import GetLockCountRequest from "./security/operations/lock/GetLockCountRequest"; +import GetLocksIdRequest from "./security/operations/lock/GetLocksIdRequest"; +import GetLockRequest from "./security/operations/lock/GetLockRequest"; +import ExecuteHoldByPartitionRequest from "./security/operations/hold/ExecuteHoldByPartitionRequest"; + +import GetControlListTypeRequest from "./security/operations/controlList/GetControlListTypeRequest"; +import InitializationRequest from "./network/InitializationRequest"; +import ConnectRequest from "./network/ConnectRequest"; +import GetConfigInfoRequest from "./management/GetConfigInfoRequest"; +import UpdateConfigRequest from "./management/UpdateConfigRequest"; +import UpdateConfigVersionRequest from "./management/UpdateConfigVersionRequest"; +import UpdateResolverRequest from "./management/UpdateResolverRequest"; +import UpdateMaturityDateRequest from "./bond/UpdateMaturityDateRequest"; +import SetScheduledBalanceAdjustmentRequest from "./equity/SetScheduledBalanceAdjustmentRequest"; +import GetScheduledBalanceAdjustmentRequest from "./equity/GetScheduledBalanceAdjustmentRequest"; +import GetScheduledBalanceAdjustmentCountRequest from "./equity/GetScheduledBalanceAdjustmentsCountRequest"; +import GetAllScheduledBalanceAdjustmentsRequest from "./equity/GetAllScheduledBalanceAdjustmentst"; +import GetLastAggregatedBalanceAdjustmentFactorForRequest from "./equity/GetLastAggregatedBalanceAdjustmentFactorForRequest"; +import GetAggregatedBalanceAdjustmentFactorRequest from "./account/GetAggregatedBalanceAdjustmentFactorRequest"; +import GetLastAggregatedBalanceAdjustmentFactorForByPartitionRequest from "./equity/GetLastAggregatedBalanceAdjustmentFactorForByPartitionRequest"; +import ProtectedTransferFromByPartitionRequest from "./security/operations/transfer/ProtectedTransferFromByPartitionRequest"; +import ProtectedRedeemFromByPartitionRequest from "./security/operations/redeem/ProtectedRedeemFromByPartitionRequest"; +import GetNounceRequest from "./security/operations/protectedPartitions/GetNounceRequest"; +import PartitionsProtectedRequest from "./security/operations/protectedPartitions/PartitionsProtectedRequest"; +import ProtectedTransferAndLockByPartitionRequest from "./security/operations/transfer/ProtectedTransferAndLockByPartitionRequest"; +import CreateHoldByPartitionRequest from "./security/operations/hold/CreateHoldByPartition"; +import CreateHoldFromByPartitionRequest from "./security/operations/hold/CreateHoldFromByPartition"; +import ControllerCreateHoldByPartitionRequest from "./security/operations/hold/ControllerCreateHoldFromByPartition"; +import ProtectedCreateHoldByPartitionRequest from "./security/operations/hold/ProtectedCreateHoldFromByPartition"; +import GetHeldAmountForRequest from "./security/operations/hold/GetHeldAmountForRequest"; +import GetHeldAmountForByPartitionRequest from "./security/operations/hold/GetHeldAmountForByPartitionRequest"; +import GetHoldCountForByPartitionRequest from "./security/operations/hold/GetHoldCountForByPartitionRequest"; +import GetHoldsIdForByPartitionRequest from "./security/operations/hold/GetHoldsIdForByPartitionRequest"; +import GetHoldForByPartitionRequest from "./security/operations/hold/GetHoldForByPartitionRequest"; +import ReleaseHoldByPartitionRequest from "./security/operations/release/ReleaseHoldByPartitionRequest"; +import ReclaimHoldByPartitionRequest from "./security/operations/hold/ReclaimHoldByPartitionRequest"; +import AddIssuerRequest from "./security/ssi/AddIssuerRequest"; +import SetRevocationRegistryAddressRequest from "./security/ssi/SetRevocationRegistryAddressRequest"; +import RemoveIssuerRequest from "./security/operations/issue/RemoveIssuerRequest"; +import GetRevocationRegistryAddressRequest from "./security/ssi/GetRevocationRegistryAddressRequest"; +import GetIssuerListCountRequest from "./security/ssi/GetIssuerListCountRequest"; +import GetIssuerListMembersRequest from "./security/ssi/GetIssuerListMembersRequest"; +import IsIssuerRequest from "./security/operations/issue/IsIssuerRequest"; +import GetKycAccountsCountRequest from "./security/kyc/GetKycAccountsCountRequest"; +import GetKycForRequest from "./security/kyc/GetKycForRequest"; +import RevokeKycRequest from "./security/kyc/RevokeKycRequest"; +import GrantKycRequest from "./security/kyc/GrantKycRequest"; +import GetKycAccountsDataRequest from "./security/kyc/GetKycAccountsDataRequest"; +import GetKycStatusForRequest from "./security/kyc/GetKycStatusForRequest"; +import ActivateClearingRequest from "./security/operations/clearing/ActivateClearingRequest"; +import DeactivateClearingRequest from "./security/operations/clearing/DeactivateClearingRequest"; +import ClearingTransferByPartitionRequest from "./security/operations/clearing/ClearingTransferByPartitionRequest"; +import ClearingTransferFromByPartitionRequest from "./security/operations/clearing/ClearingTransferFromByPartitionRequest"; +import ProtectedClearingTransferByPartitionRequest from "./security/operations/clearing/ProtectedClearingTransferByPartitionRequest"; +import ApproveClearingOperationByPartitionRequest from "./security/operations/clearing/ApproveClearingOperationByPartitionRequest"; +import CancelClearingOperationByPartitionRequest from "./security/operations/clearing/CancelClearingOperationByPartitionRequest"; +import ReclaimClearingOperationByPartitionRequest from "./security/operations/clearing/ReclaimClearingOperationByPartitionRequest"; +import ClearingRedeemByPartitionRequest from "./security/operations/clearing/ClearingRedeemByPartitionRequest"; +import ClearingRedeemFromByPartitionRequest from "./security/operations/clearing/ClearingRedeemFromByPartitionRequest"; +import ProtectedClearingRedeemByPartitionRequest from "./security/operations/clearing/ProtectedClearingRedeemByPartitionRequest"; +import ClearingCreateHoldByPartitionRequest from "./security/operations/clearing/ClearingCreateHoldByPartitionRequest"; +import ClearingCreateHoldFromByPartitionRequest from "./security/operations/clearing/ClearingCreateHoldFromByPartitionRequest"; +import ProtectedClearingCreateHoldByPartitionRequest from "./security/operations/clearing/ProtectedClearingCreateHoldByPartitionRequest"; +import GetClearedAmountForByPartitionRequest from "./security/operations/clearing/GetClearedAmountForByPartitionRequest"; +import GetClearedAmountForRequest from "./security/operations/clearing/GetClearedAmountForRequest"; +import GetClearingCountForByPartitionRequest from "./security/operations/clearing/GetClearingCountForByPartitionRequest"; +import GetClearingsIdForByPartitionRequest from "./security/operations/clearing/GetClearingsIdForByPartitionRequest"; +import IsClearingActivatedRequest from "./security/operations/clearing/IsClearingActivatedRequest"; +import OperatorClearingCreateHoldByPartitionRequest from "./security/operations/clearing/OperatorClearingCreateHoldByPartitionRequest"; +import OperatorClearingRedeemByPartitionRequest from "./security/operations/clearing/OperatorClearingRedeemByPartitionRequest"; +import OperatorClearingTransferByPartitionRequest from "./security/operations/clearing/OperatorClearingTransferByPartitionRequest"; +import GetClearingCreateHoldForByPartitionRequest from "./security/operations/clearing/GetClearingCreateHoldForByPartitionRequest"; +import GetClearingRedeemForByPartitionRequest from "./security/operations/clearing/GetClearingRedeemForByPartitionRequest"; +import GetClearingTransferForByPartitionRequest from "./security/operations/clearing/GetClearingTransferForByPartitionRequest"; +import UpdateExternalPausesRequest from "./security/externalPauses/UpdateExternalPausesRequest"; +import AddExternalPauseRequest from "./security/externalPauses/AddExternalPauseRequest"; +import RemoveExternalPauseRequest from "./security/externalPauses/RemoveExternalPauseRequest"; +import IsExternalPauseRequest from "./security/externalPauses/IsExternalPauseRequest"; +import GetExternalPausesCountRequest from "./security/externalPauses/GetExternalPausesCountRequest"; +import GetExternalPausesMembersRequest from "./security/externalPauses/GetExternalPausesMembersRequest"; +import IsPausedMockRequest from "./security/externalPauses/mock/IsPausedMockRequest"; +import SetPausedMockRequest from "./security/externalPauses/mock/SetPausedMockRequest"; +import UpdateExternalControlListsRequest from "./security/externalControlLists/UpdateExternalControlListsRequest"; +import AddExternalControlListRequest from "./security/externalControlLists/AddExternalControlListRequest"; +import RemoveExternalControlListRequest from "./security/externalControlLists/RemoveExternalControlListRequest"; +import GetExternalControlListsCountRequest from "./security/externalControlLists/GetExternalControlListsCountRequest"; +import IsExternalControlListRequest from "./security/externalControlLists/IsExternalControlListRequest"; +import GetExternalControlListsMembersRequest from "./security/externalControlLists/GetExternalControlListsMembersRequest"; +import AddToBlackListMockRequest from "./security/externalControlLists/mock/AddToBlackListMockRequest"; +import AddToWhiteListMockRequest from "./security/externalControlLists/mock/AddToWhiteListMockRequest"; +import RemoveFromBlackListMockRequest from "./security/externalControlLists/mock/RemoveFromBlackListMockRequest"; +import RemoveFromWhiteListMockRequest from "./security/externalControlLists/mock/RemoveFromWhiteListMockRequest"; +import IsAuthorizedBlackListMockRequest from "./security/externalControlLists/mock/IsAuthorizedBlackListMockRequest"; +import IsAuthorizedWhiteListMockRequest from "./security/externalControlLists/mock/IsAuthorizedWhiteListMockRequest"; +import UpdateExternalKycListsRequest from "./security/externalKycLists/UpdateExternalKycListsRequest"; +import AddExternalKycListRequest from "./security/externalKycLists/AddExternalKycListRequest"; +import RemoveExternalKycListRequest from "./security/externalKycLists/RemoveExternalKycListRequest"; +import GetExternalKycListsCountRequest from "./security/externalKycLists/GetExternalKycListsCountRequest"; +import GetExternalKycListsMembersRequest from "./security/externalKycLists/GetExternalKycListsMembersRequest"; +import IsExternalKycListRequest from "./security/externalKycLists/IsExternalKycListRequest"; +import IsExternallyGrantedRequest from "./security/externalKycLists/IsExternallyGrantedRequest"; +import ActivateInternalKycRequest from "./security/kyc/ActivateInternalKycRequest"; +import IsInternalKycActivatedRequest from "./security/kyc/IsInternalKycActivatedRequest"; +import GrantKycMockRequest from "./security/externalKycLists/mock/GrantKycMockRequest"; +import RevokeKycMockRequest from "./security/externalKycLists/mock/RevokeKycMockRequest"; +import GetKycStatusMockRequest from "./security/externalKycLists/mock/GetKycStatusMockRequest"; +import SetNameRequest from "./security/operations/tokeMetadata/SetNameRequest"; +import SetSymbolRequest from "./security/operations/tokeMetadata/SetSymbolRequest"; +import SetOnchainIDRequest from "./security/operations/tokeMetadata/SetOnchainIDRequest"; +import SetComplianceRequest from "./security/compliance/SetComplianceRequest"; +import ComplianceRequest from "./security/compliance/ComplianceRequest"; +import SetIdentityRegistryRequest from "./security/identityRegistry/SetIdentityRegistryRequest"; +import IdentityRegistryRequest from "./security/identityRegistry/IdentityRegistryRequest"; +import OnchainIDRequest from "./security/operations/tokeMetadata/OnchainIDRequest"; +import BurnRequest from "./security/operations/burn/BurnRequest"; +import MintRequest from "./security/operations/mint/MintRequest"; +import RecoveryAddressRequest from "./security/operations/recovery/RecoveryAddressRequest"; +import IsAddressRecoveredRequest from "./security/operations/recovery/IsAddressRecoveredRequest"; +import ForcedTransferRequest from "./security/operations/transfer/ForcedTransferRequest"; +import FreezePartialTokensRequest from "./security/operations/freeze/FreezePartialTokensRequest"; +import GetFrozenPartialTokensRequest from "./security/operations/freeze/GetFrozenPartialTokensRequest"; +import UnfreezePartialTokensRequest from "./security/operations/freeze/UnfreezePartialTokensRequest"; +import AddAgentRequest from "./security/operations/agent/AddAgentRequest"; +import RemoveAgentRequest from "./security/operations/agent/RemoveAgentRequest"; +import BatchBurnRequest from "./security/operations/batch/BatchBurnRequest"; +import BatchForcedTransferRequest from "./security/operations/batch/BatchForcedTransferRequest"; +import BatchFreezePartialTokensRequest from "./security/operations/batch/BatchFreezePartialTokensRequest"; +import BatchMintRequest from "./security/operations/batch/BatchMintRequest"; +import BatchSetAddressFrozenRequest from "./security/operations/batch/BatchSetAddressFrozenRequest"; +import BatchTransferRequest from "./security/operations/batch/BatchTransferRequest"; +import BatchUnfreezePartialTokensRequest from "./security/operations/batch/BatchUnfreezePartialTokensRequest"; +import SetAddressFrozenRequest from "./security/operations/freeze/SetAddressFrozenRequest"; +import DeactivateInternalKycRequest from "./security/kyc/DeactivateInternalKycRequest"; +import TakeSnapshotRequest from "./security/operations/snapshot/TakeSnapshotRequest"; +import RedeemAtMaturityByPartitionRequest from "./bond/RedeemAtMaturityByPartitionRequest"; +import FullRedeemAtMaturityRequest from "./bond/FullRedeemAtMaturityRequest"; +import GetTokenHoldersAtSnapshotRequest from "./security/operations/snapshot/GetTokenHoldersAtSnapshotRequest"; +import GetTotalTokenHoldersAtSnapshotRequest from "./security/operations/snapshot/GetTotalTokenHoldersAtSnapshotRequest"; +import GetCouponHoldersRequest from "./bond/GetCouponHoldersRequest"; +import GetTotalCouponHoldersRequest from "./bond/GetTotalCouponHoldersRequest"; +import GetDividendHoldersRequest from "./equity/GetDividendHoldersRequest"; +import GetTotalDividendHoldersRequest from "./equity/GetTotalDividendHoldersRequest"; +import GetTotalVotingHoldersRequest from "./equity/GetTotalVotingHoldersRequest"; +import GetVotingHoldersRequest from "./equity/GetVotingHoldersRequest"; +import GetSecurityHoldersRequest from "./security/GetSecurityHoldersRequest"; +import GetTotalSecurityHoldersRequest from "./security/GetTotalSecurityHoldersRequest"; +import CreateTrexSuiteEquityRequest from "./equity/CreateTrexSuiteEquityRequest"; +import CreateTrexSuiteBondRequest from "./bond/CreateTrexSuiteBondRequest"; +import AddProceedRecipientRequest from "./bond/AddProceedRecipientRequest"; +import RemoveProceedRecipientRequest from "./bond/RemoveProceedRecipientRequest"; +import UpdateProceedRecipientDataRequest from "./bond/UpdateProceedRecipientDataRequest"; +import GetProceedRecipientDataRequest from "./bond/GetProceedRecipientDataRequest"; +import GetProceedRecipientsCountRequest from "./bond/GetProceedRecipientsCountRequest"; +import GetProceedRecipientsRequest from "./bond/GetProceedRecipientsRequest"; +import IsProceedRecipientRequest from "./bond/IsProceedRecipientRequest"; +import GetPrincipalForRequest from "./bond/GetPrincipalForRequest"; +import ActionContentHashExistsRequest from "./security/operations/corporateActions/ActionContentHashExistsRequest"; export { CreateEquityRequest, @@ -600,4 +601,5 @@ export { GetProceedRecipientDataRequest, GetProceedRecipientsCountRequest, GetProceedRecipientsRequest, + ActionContentHashExistsRequest, }; diff --git a/packages/ats/sdk/src/port/in/request/security/operations/corporateActions/ActionContentHashExistsRequest.ts b/packages/ats/sdk/src/port/in/request/security/operations/corporateActions/ActionContentHashExistsRequest.ts new file mode 100644 index 000000000..64fcbd453 --- /dev/null +++ b/packages/ats/sdk/src/port/in/request/security/operations/corporateActions/ActionContentHashExistsRequest.ts @@ -0,0 +1,222 @@ +/* + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +*/ + +import ValidatedRequest from "@core/validation/ValidatedArgs"; +import FormatValidation from "@port/in/request/FormatValidation"; + +export default class ActionContentHashExistsRequest extends ValidatedRequest { + securityId: string; + contentHash: string; + + constructor({ securityId, contentHash }: { securityId: string; contentHash: string }) { + super({ + securityId: FormatValidation.checkHederaIdFormatOrEvmAddress(), + contentHash: FormatValidation.checkBytes32Format(), + }); + + this.securityId = securityId; + this.contentHash = contentHash; + } +} diff --git a/packages/ats/sdk/src/port/in/security/corporateActions/CorporateActions.ts b/packages/ats/sdk/src/port/in/security/corporateActions/CorporateActions.ts new file mode 100644 index 000000000..9808307e6 --- /dev/null +++ b/packages/ats/sdk/src/port/in/security/corporateActions/CorporateActions.ts @@ -0,0 +1,235 @@ +/* + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +*/ + +/* eslint-disable @typescript-eslint/no-unused-vars */ +import { LogError } from "@core/decorator/LogErrorDecorator"; +import ValidatedRequest from "@core/validation/ValidatedArgs"; +import { QueryBus } from "@core/query/QueryBus"; +import Injectable from "@core/injectable/Injectable"; +import { CommandBus } from "@core/command/CommandBus"; +import { ActionContentHashExistsQuery } from "@query/security/actionContentHashExists/ActionContentHashExistsQuery"; +import { ActionContentHashExistsRequest } from "../../request"; + +interface ICorporateActionsInPort { + actionContentHashExists(request: ActionContentHashExistsRequest): Promise; +} + +class CorporateActionsInPort implements ICorporateActionsInPort { + constructor( + private readonly commandBus: CommandBus = Injectable.resolve(CommandBus), + private readonly queryBus: QueryBus = Injectable.resolve(QueryBus), + ) {} + + @LogError + async actionContentHashExists(request: ActionContentHashExistsRequest): Promise { + const { securityId, contentHash } = request; + ValidatedRequest.handleValidation("ActionContentHashExistsRequest", request); + + return (await this.queryBus.execute(new ActionContentHashExistsQuery(securityId, contentHash))).payload; + } +} + +const CorporateActions = new CorporateActionsInPort(); +export default CorporateActions; diff --git a/packages/ats/sdk/src/port/in/security/corporateActions/CorporateActions.unit.test.ts b/packages/ats/sdk/src/port/in/security/corporateActions/CorporateActions.unit.test.ts new file mode 100644 index 000000000..92896428b --- /dev/null +++ b/packages/ats/sdk/src/port/in/security/corporateActions/CorporateActions.unit.test.ts @@ -0,0 +1,303 @@ +/* + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +*/ + +import { createMock } from "@golevelup/ts-jest"; +import { ActionContentHashExistsRequest } from "../../request"; +import LogService from "@service/log/LogService"; +import { QueryBus } from "@core/query/QueryBus"; +import ValidatedRequest from "@core/validation/ValidatedArgs"; +import { ValidationError } from "@core/validation/ValidationError"; +import CorporateActions from "./CorporateActions"; + +import { ActionContentHashExistsRequestFixture } from "@test/fixtures/corporateActions/CorporateActionsFixture"; +import { ActionContentHashExistsQuery } from "@query/security/actionContentHashExists/ActionContentHashExistsQuery"; + +describe("Corporate Actions", () => { + let queryBusMock: jest.Mocked; + + let actionContentHashExistsRequest: ActionContentHashExistsRequest; + + let handleValidationSpy: jest.SpyInstance; + + beforeEach(() => { + queryBusMock = createMock(); + + handleValidationSpy = jest.spyOn(ValidatedRequest, "handleValidation"); + jest.spyOn(LogService, "logError").mockImplementation(() => {}); + (CorporateActions as any).queryBus = queryBusMock; + }); + + afterEach(() => { + jest.resetAllMocks(); + jest.restoreAllMocks(); + }); + + describe("ActionContentHashExists", () => { + actionContentHashExistsRequest = new ActionContentHashExistsRequest(ActionContentHashExistsRequestFixture.create()); + + const expectedResponse = { + payload: true, + }; + it("should check action content hash exist successfully", async () => { + queryBusMock.execute.mockResolvedValue(expectedResponse); + + const result = await CorporateActions.actionContentHashExists(actionContentHashExistsRequest); + + expect(handleValidationSpy).toHaveBeenCalledWith( + "ActionContentHashExistsRequest", + actionContentHashExistsRequest, + ); + + expect(queryBusMock.execute).toHaveBeenCalledWith( + new ActionContentHashExistsQuery( + actionContentHashExistsRequest.securityId, + actionContentHashExistsRequest.contentHash, + ), + ); + expect(result).toEqual(expectedResponse.payload); + }); + + it("should throw an error if query execution fails", async () => { + const error = new Error("Query execution failed"); + queryBusMock.execute.mockRejectedValue(error); + + await expect(CorporateActions.actionContentHashExists(actionContentHashExistsRequest)).rejects.toThrow( + "Query execution failed", + ); + + expect(handleValidationSpy).toHaveBeenCalledWith("ActionContentHashExistsRequest", actionContentHashExistsRequest); + + expect(queryBusMock.execute).toHaveBeenCalledWith( + new ActionContentHashExistsQuery( + actionContentHashExistsRequest.securityId, + actionContentHashExistsRequest.contentHash, + ), + ); + }); + + it("should throw error if securityId is invalid", async () => { + actionContentHashExistsRequest = new ActionContentHashExistsRequest({ + ...ActionContentHashExistsRequestFixture.create({ + securityId: "invalid", + }), + }); + + await expect(CorporateActions.actionContentHashExists(actionContentHashExistsRequest)).rejects.toThrow( + ValidationError, + ); + }); + it("should throw error if content hash is invalid", async () => { + actionContentHashExistsRequest = new ActionContentHashExistsRequest({ + ...ActionContentHashExistsRequestFixture.create({ + contentHash: "invalid", + }), + }); + + await expect(CorporateActions.actionContentHashExists(actionContentHashExistsRequest)).rejects.toThrow( + ValidationError, + ); + }); + }); +}); diff --git a/packages/ats/sdk/src/port/out/hs/HederaTransactionAdapter.ts b/packages/ats/sdk/src/port/out/hs/HederaTransactionAdapter.ts index 7f3f565a3..a351d2a60 100644 --- a/packages/ats/sdk/src/port/out/hs/HederaTransactionAdapter.ts +++ b/packages/ats/sdk/src/port/out/hs/HederaTransactionAdapter.ts @@ -312,6 +312,8 @@ import { import { MissingRegulationSubType } from '@domain/context/factory/error/MissingRegulationSubType'; import { MissingRegulationType } from '@domain/context/factory/error/MissingRegulationType'; import { BaseContract, Contract, ContractTransaction } from 'ethers'; +import { ProtectionData } from '@domain/context/factory/ProtectionData'; + export abstract class HederaTransactionAdapter extends TransactionAdapter { mirrorNodes: MirrorNodes; @@ -953,6 +955,12 @@ export abstract class HederaTransactionAdapter extends TransactionAdapter { expirationTimestamp: expirationDate.toBigNumber(), }; + const protectionData: ProtectionData = { + deadline: deadline.toBigNumber(), + nounce: nounce.toBigNumber(), + signature: signature + } + return this.executeWithArgs( new TransferAndLockFacet__factory().attach(security.toString()), 'protectedTransferAndLockByPartition', @@ -961,9 +969,7 @@ export abstract class HederaTransactionAdapter extends TransactionAdapter { [ partitionId, transferAndLockData, - deadline.toBigNumber(), - nounce.toBigNumber(), - signature, + protectionData, ], ); } @@ -1501,6 +1507,12 @@ export abstract class HederaTransactionAdapter extends TransactionAdapter { `Protected Redeeming ${amount} securities from account ${sourceId.toString()}`, ); + const protectionData: ProtectionData = { + deadline: deadline.toBigNumber(), + nounce: nounce.toBigNumber(), + signature: signature + } + return this.executeWithArgs( new ERC1410ManagementFacet__factory().attach(security.toString()), 'protectedRedeemFromByPartition', @@ -1510,9 +1522,7 @@ export abstract class HederaTransactionAdapter extends TransactionAdapter { partitionId, sourceId.toString(), amount.toBigNumber(), - deadline.toBigNumber(), - nounce.toBigNumber(), - signature, + protectionData, ], ); } @@ -1531,6 +1541,13 @@ export abstract class HederaTransactionAdapter extends TransactionAdapter { LogService.logTrace( `Protected Transfering ${amount} securities from account ${sourceId.toString()} to account ${targetId.toString()}`, ); + + const protectionData: ProtectionData = { + deadline: deadline.toBigNumber(), + nounce: nounce.toBigNumber(), + signature: signature + } + return this.executeWithArgs( new ERC1410ManagementFacet__factory().attach(security.toString()), 'protectedTransferFromByPartition', @@ -1541,9 +1558,7 @@ export abstract class HederaTransactionAdapter extends TransactionAdapter { sourceId.toString(), targetId.toString(), amount.toBigNumber(), - deadline.toBigNumber(), - nounce.toBigNumber(), - signature, + protectionData, ], ); } @@ -1569,6 +1584,13 @@ export abstract class HederaTransactionAdapter extends TransactionAdapter { data: '0x', expirationTimestamp: expirationDate.toBigNumber(), }; + + const protectionData: ProtectionData = { + deadline: deadline.toBigNumber(), + nounce: nounce.toBigNumber(), + signature: signature + } + return this.executeWithArgs( new TransferAndLockFacet__factory().attach(security.toString()), 'protectedTransferAndLock', @@ -1576,9 +1598,7 @@ export abstract class HederaTransactionAdapter extends TransactionAdapter { GAS.PROTECTED_TRANSFER_AND_LOCK, [ transferAndLockData, - deadline.toBigNumber(), - nounce.toBigNumber(), - signature, + protectionData, ], ); } diff --git a/packages/ats/sdk/src/port/out/rpc/RPCQueryAdapter.ts b/packages/ats/sdk/src/port/out/rpc/RPCQueryAdapter.ts index 2207b4e72..d86179410 100644 --- a/packages/ats/sdk/src/port/out/rpc/RPCQueryAdapter.ts +++ b/packages/ats/sdk/src/port/out/rpc/RPCQueryAdapter.ts @@ -260,6 +260,7 @@ import { ERC3643ReadFacet__factory, TREXFactoryAts__factory, ProceedRecipientsFacet__factory, + CorporateActionsFacet__factory, } from '@hashgraph/asset-tokenization-contracts'; import { ScheduledSnapshot } from '@domain/context/security/ScheduledSnapshot'; import { VotingRights } from '@domain/context/equity/VotingRights'; @@ -2139,6 +2140,7 @@ export class RPCQueryAdapter { ).getProceedRecipientsCount() ).toNumber(); } + async getProceedRecipients( address: EvmAddress, page: number, @@ -2152,4 +2154,17 @@ export class RPCQueryAdapter { address.toString(), ).getProceedRecipients(page, pageLength); } + + async actionContentHashExists( + address: EvmAddress, + contentHash: string, + ): Promise { + LogService.logTrace( + `Getting actionContentHashExists for ${contentHash} for the security: ${address.toString()}`, + ); + return await this.connect( + CorporateActionsFacet__factory, + address.toString(), + ).actionContentHashExists(contentHash); + } } diff --git a/packages/ats/sdk/src/port/out/rpc/RPCTransactionAdapter.ts b/packages/ats/sdk/src/port/out/rpc/RPCTransactionAdapter.ts index 7cbb7048f..642e27b8e 100644 --- a/packages/ats/sdk/src/port/out/rpc/RPCTransactionAdapter.ts +++ b/packages/ats/sdk/src/port/out/rpc/RPCTransactionAdapter.ts @@ -309,6 +309,7 @@ import { import { SecurityDataBuilder } from '@domain/context/util/SecurityDataBuilder'; import NetworkService from '@service/network/NetworkService'; import MetamaskService from '@service/wallet/metamask/MetamaskService'; +import { ProtectionData } from '@domain/context/factory/ProtectionData'; @singleton() export class RPCTransactionAdapter extends TransactionAdapter { @@ -1297,6 +1298,12 @@ export class RPCTransactionAdapter extends TransactionAdapter { `Protected Redeeming ${amount} securities from account ${sourceId.toString()}`, ); + const protectionData: ProtectionData = { + deadline: deadline.toBigNumber(), + nounce: nounce.toBigNumber(), + signature: signature + } + return this.executeTransaction( ERC1410ManagementFacet__factory.connect( security.toString(), @@ -1307,9 +1314,7 @@ export class RPCTransactionAdapter extends TransactionAdapter { partitionId, sourceId.toString(), amount.toBigNumber(), - deadline.toBigNumber(), - nounce.toBigNumber(), - signature, + protectionData, ], GAS.PROTECTED_REDEEM, ); @@ -1329,6 +1334,12 @@ export class RPCTransactionAdapter extends TransactionAdapter { `Protected Transfering ${amount} securities from account ${sourceId.toString()} to account ${targetId.toString()}`, ); + const protectionData: ProtectionData = { + deadline: deadline.toBigNumber(), + nounce: nounce.toBigNumber(), + signature: signature + } + return this.executeTransaction( ERC1410ManagementFacet__factory.connect( security.toString(), @@ -1340,9 +1351,7 @@ export class RPCTransactionAdapter extends TransactionAdapter { sourceId.toString(), targetId.toString(), amount.toBigNumber(), - deadline.toBigNumber(), - nounce.toBigNumber(), - signature, + protectionData, ], GAS.PROTECTED_TRANSFER, ); @@ -1371,6 +1380,12 @@ export class RPCTransactionAdapter extends TransactionAdapter { expirationTimestamp: expirationDate.toBigNumber(), }; + const protectionData: ProtectionData = { + deadline: deadline.toBigNumber(), + nounce: nounce.toBigNumber(), + signature: signature + } + return this.executeTransaction( TransferAndLockFacet__factory.connect( security.toString(), @@ -1380,9 +1395,7 @@ export class RPCTransactionAdapter extends TransactionAdapter { [ partitionId, transferAndLockData, - deadline.toBigNumber(), - nounce.toBigNumber(), - signature, + protectionData, ], GAS.PROTECTED_TRANSFER_AND_LOCK, );