Skip to main content

ILockByPartition

Asset Tokenization Studio Team

ILockByPartition

Interface for partition-aware token lock operations and partition-scoped read queries.

Aggregates the partition-aware write methods (lockByPartition, releaseByPartition) and the partition-scoped read methods (getLockedAmountForByPartition, getLockCountForByPartition, getLocksIdForByPartition, getLockForByPartition) into a single interface separate from the default-partition ILock surface. Inherits ILockTypes for the events and errors shared with ILock.

Methods​

getLockCountForByPartition​

function getLockCountForByPartition(bytes32 _partition, address _tokenHolder) external view returns (uint256 lockCount_)

Returns the number of active locks held by _tokenHolder on _partition.

Parameters​

NameTypeDescription
_partitionbytes32The partition the query is scoped to.
_tokenHolderaddressThe address whose lock count is queried.

Returns​

NameTypeDescription
lockCount_uint256The number of active locks on the given partition.

getLockForByPartition​

function getLockForByPartition(bytes32 _partition, address _tokenHolder, uint256 _lockId) external view returns (uint256 amount_, uint256 expirationTimestamp_)

Returns the amount and expiration of a lock on _partition.

Both fields are zero when the identifier does not exist for the given (_partition, _tokenHolder) pair. The amount is adjusted by any pending balance-adjustment factors.

Parameters​

NameTypeDescription
_partitionbytes32The partition the lock lives on.
_tokenHolderaddressThe address whose lock is queried.
_lockIduint256Identifier of the lock to read.

Returns​

NameTypeDescription
amount_uint256The locked amount, in token base units.
expirationTimestamp_uint256Unix timestamp at which the lock becomes releasable.

getLockedAmountForByPartition​

function getLockedAmountForByPartition(bytes32 _partition, address _tokenHolder) external view returns (uint256 amount_)

Returns the total locked amount of _tokenHolder on _partition, adjusted by any pending balance-adjustment factors.

Parameters​

NameTypeDescription
_partitionbytes32The partition the query is scoped to.
_tokenHolderaddressThe address whose locked amount is queried.

Returns​

NameTypeDescription
amount_uint256The locked amount on the given partition.

getLocksIdForByPartition​

function getLocksIdForByPartition(bytes32 _partition, address _tokenHolder, uint256 _pageIndex, uint256 _pageLength) external view returns (uint256[] locksId_)

Returns a paginated list of lock identifiers for _tokenHolder on _partition.

Pagination is bounded by the caller through _pageLength; the returned array length is at most _pageLength. A query past the available range returns an empty array.

Parameters​

NameTypeDescription
_partitionbytes32The partition the query is scoped to.
_tokenHolderaddressThe address whose locks are listed.
_pageIndexuint256Zero-based index of the page to retrieve.
_pageLengthuint256Maximum number of identifiers to return on the page.

Returns​

NameTypeDescription
locksId_uint256[]Array of lock identifiers for the requested page.

initializeLockByPartition​

function initializeLockByPartition() external nonpayable

Initialises the lock-by-partition capability on the token.

Callable once; subsequent calls revert with FacetAlreadyRegistered. Requires DEFAULT_ADMIN_ROLE. Called by the factory during deployment.

lockByPartition​

function lockByPartition(bytes32 _partition, uint256 _amount, address _tokenHolder, uint256 _expirationTimestamp) external nonpayable returns (uint256 lockId_)

Locks _amount tokens of _tokenHolder on _partition until _expirationTimestamp.

Callers must hold ROLE_LOCKER. The implementation enforces the unpaused state, a future expiration timestamp, an unrecovered token holder and the single-partition / default-partition rule. Emits LockedByPartition.

Parameters​

NameTypeDescription
_partitionbytes32The partition the tokens are locked on.
_amountuint256The amount of tokens to lock.
_tokenHolderaddressThe address whose tokens are locked.
_expirationTimestampuint256Unix timestamp at which the lock becomes releasable.

Returns​

NameTypeDescription
lockId_uint256Identifier assigned to the new lock for (partition, tokenHolder).

releaseByPartition​

function releaseByPartition(bytes32 _partition, uint256 _lockId, address _tokenHolder) external nonpayable returns (bool success_)

Releases a lock on _partition previously created with lockByPartition.

Pause-gated and validated against single-partition mode. Reverts with WrongLockId when _lockId is unknown for (_partition, _tokenHolder) and with LockExpirationNotReached before the lock expires. Emits LockByPartitionReleased.

Parameters​

NameTypeDescription
_partitionbytes32The partition the lock lives on.
_lockIduint256Identifier of the lock to release.
_tokenHolderaddressThe address whose tokens are returned.

Returns​

NameTypeDescription
success_boolTrue when the lock has been removed and the balance returned.

updateLockExpirationByPartition​

function updateLockExpirationByPartition(bytes32 _partition, address _tokenHolder, uint256 _lockId, uint256 _newExpirationTimestamp) external nonpayable returns (bool success_)

Updates the expiration timestamp of an existing lock on _partition.

Callers must hold ROLE_LOCKER. The new timestamp must be in the future. Both shortening and extending are allowed — this is an intentional trusted-role design: a second locker can correct an excessively far expiration set by a compromised account, while an admin can revoke the malicious locker's role if needed. Emits LockExpirationUpdated.

Parameters​

NameTypeDescription
_partitionbytes32The partition the lock lives on.
_tokenHolderaddressThe address whose lock expiration is being updated.
_lockIduint256Identifier of the lock to update.
_newExpirationTimestampuint256New Unix timestamp at which the lock becomes releasable.

Returns​

NameTypeDescription
success_boolTrue when the expiration timestamp has been updated.

Events​

LockByPartitionInitialized​

event LockByPartitionInitialized()

Emitted once when the lock-by-partition capability is initialised on a token.

Fires exclusively from initializeLockByPartition.

LockByPartitionReleased​

event LockByPartitionReleased(address indexed operator, address indexed tokenHolder, bytes32 indexed partition, uint256 lockId)

Emitted when a previously created lock is released back to its token holder.

Emitted by release, releaseByPartition and forceReleaseByPartition. The released amount is not part of the event because the underlying lock entry is removed atomically; consumers can correlate with the prior LockedByPartition via (partition, tokenHolder, lockId).

Parameters​

NameTypeDescription
operator indexedaddressThe caller that requested the release.
tokenHolder indexedaddressThe address the tokens are returned to.
partition indexedbytes32The partition the lock was held on.
lockIduint256The identifier of the lock that has been released.

LockExpirationUpdated​

event LockExpirationUpdated(address indexed operator, address indexed tokenHolder, bytes32 indexed partition, uint256 lockId, uint256 oldExpirationTimestamp, uint256 newExpirationTimestamp)

Emitted when a lock's expiration timestamp is updated by a locker.

Emitted by both updateLockExpiration (default partition) and updateLockExpirationByPartition (any partition).

Parameters​

NameTypeDescription
operator indexedaddressThe caller that requested the update (must hold ROLE_LOCKER).
tokenHolder indexedaddressThe address whose lock expiration is being updated.
partition indexedbytes32The partition the lock lives on.
lockIduint256The identifier of the lock being updated.
oldExpirationTimestampuint256The expiration timestamp before the update.
newExpirationTimestampuint256The new expiration timestamp after the update.

LockedByPartition​

event LockedByPartition(address indexed operator, address indexed tokenHolder, bytes32 indexed partition, uint256 lockId, uint256 amount, uint256 expirationTimestamp)

Emitted when an amount of tokens is locked on a specific partition until an expiration timestamp.

Emitted by both lock (default partition) and lockByPartition (any partition) so consumers can monitor every lock creation through a single topic.

Parameters​

NameTypeDescription
operator indexedaddressThe caller that requested the lock (typically holds ROLE_LOCKER).
tokenHolder indexedaddressThe address whose tokens are locked.
partition indexedbytes32The partition the tokens are locked on.
lockIduint256The identifier assigned to the new lock for (partition, tokenHolder).
amountuint256The amount of tokens locked.
expirationTimestampuint256The Unix timestamp at which the lock becomes releasable.

Errors​

InvalidLockAmount​

error InvalidLockAmount()

Reverts when a lock creation is attempted with a zero amount.

Checked at the start of LockStorageWrapper.lockByPartition, which is the single entry point shared by both Lock.lock and LockByPartition.lockByPartition.

LockExpirationNotReached​

error LockExpirationNotReached()

Reverts when a release is attempted before the lock's expiration timestamp.

Used by the onlyWithLockedExpirationTimestamp modifier and by LockStorageWrapper.checkLockedExpirationTimestamp.

WrongLockId​

error WrongLockId()

Reverts when a lock identifier does not exist for the given (partition, tokenHolder) pair.

Used by the onlyWithValidLockId modifier and by LockStorageWrapper.checkValidLockId.