Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
4f6f58f
fix: partition returned as bytes32 in transfer operations. protected …
AlbertoMolinaIoBuilders Dec 3, 2025
1bba972
fix: onlypause added to batchsetaddressfrozen method (#722)
AlbertoMolinaIoBuilders Dec 3, 2025
1a766aa
feat: sdk with new protected data struct
AlbertoMolinaIoBuilders Dec 3, 2025
9af3566
fix: corporate action duplicate checks (#724)
AlbertoMolinaIoBuilders Dec 4, 2025
a4d31a9
feat:sdk with action content exists method from ca
AlbertoMolinaIoBuilders Dec 4, 2025
76546c3
fix: sdk test fixes
AlbertoMolinaIoBuilders Dec 4, 2025
1f6f414
fix: batch set address frozen checks invalid addresses (#726)
AlbertoMolinaIoBuilders Dec 4, 2025
85d1e3b
fix: address 0 checks added to initializer of all external lists and …
AlbertoMolinaIoBuilders Dec 4, 2025
a939952
fix: code refactored to save gas when delegating in erc20votes (#728)
AlbertoMolinaIoBuilders Dec 4, 2025
0cacaca
fix: type fixed "_getScheduledBalanceAdjusment" (#729)
AlbertoMolinaIoBuilders Dec 4, 2025
f6878a0
fix: _removeLabafLock duplicated removed (#730)
AlbertoMolinaIoBuilders Dec 4, 2025
ec60b6c
fix: redundant calls to _adjustHoldBalances removed (#731)
AlbertoMolinaIoBuilders Dec 4, 2025
611f2ed
fix: getStaticInterfaceIds array adjusted (#732)
AlbertoMolinaIoBuilders Dec 4, 2025
b04363c
fix: todo comments removed
AlbertoMolinaIoBuilders Dec 4, 2025
4e15c4c
Merge remote-tracking branch 'origin/develop' into auditIssues
AlbertoMolinaIoBuilders Dec 4, 2025
1a304ff
fix: tests bug fix
AlbertoMolinaIoBuilders Dec 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ interface TRexIFactory {
uint256 version;
}

// TODO: Separete common data in new struct
struct SecurityData {
bool arePartitionsProtected;
bool isMultiPartition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ interface IFactory {
uint256 version;
}

// TODO: Separete common data in new struct
struct SecurityData {
bool arePartitionsProtected;
bool isMultiPartition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,49 @@ 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(
bytes32 _partition,
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, "", "");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
);
Expand All @@ -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
);
Expand All @@ -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
);
Expand All @@ -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) {
Expand All @@ -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 {
Expand Down Expand Up @@ -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,
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ abstract contract ExternalListManagementStorageWrapper is SsiManagementStorageWr
EnumerableSet.AddressSet list;
}

error ZeroAddressNotAllowed();

function _updateExternalLists(
bytes32 _position,
address[] calldata _lists,
bool[] calldata _actives
) 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]);
Expand Down Expand Up @@ -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_) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,29 +65,31 @@ 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(
bytes32 _partition,
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(),
Expand All @@ -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(),
Expand Down
Loading
Loading