Skip to content

Commit

Permalink
Add extraData for hook context
Browse files Browse the repository at this point in the history
  • Loading branch information
boyuanx committed Dec 26, 2023
1 parent 333354c commit e853d74
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 58 deletions.
26 changes: 16 additions & 10 deletions contracts/core/TokenTableUnlockerV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ contract TokenTableUnlockerV2 is

// solhint-disable-next-line ordering
function createPresets(
bytes32[] memory presetIds,
Preset[] memory presets,
uint256 batchId
bytes32[] calldata presetIds,
Preset[] calldata presets,
uint256 batchId,
bytes[] calldata
) external virtual override onlyOwner {
for (uint256 i = 0; i < presetIds.length; i++) {
_createPreset(presetIds[i], presets[i], batchId);
Expand All @@ -74,10 +75,11 @@ contract TokenTableUnlockerV2 is
}

function createActuals(
address[] memory recipients,
Actual[] memory actuals_,
address[] calldata recipients,
Actual[] calldata actuals_,
uint256[] calldata recipientIds,
uint256 batchId
uint256 batchId,
bytes[] calldata
) external virtual override onlyOwner {
for (uint256 i = 0; i < recipients.length; i++) {
_createActual(recipients[i], actuals_[i], recipientIds[i], batchId);
Expand All @@ -86,7 +88,8 @@ contract TokenTableUnlockerV2 is
}

function withdrawDeposit(
uint256 amount
uint256 amount,
bytes calldata
) external virtual override onlyOwner {
if (!isWithdrawable) revert NotPermissioned();
IERC20(getProjectToken()).safeTransfer(_msgSender(), amount);
Expand All @@ -97,7 +100,8 @@ contract TokenTableUnlockerV2 is
function claim(
uint256[] calldata actualIds,
address[] calldata claimTos,
uint256 batchId
uint256 batchId,
bytes[] calldata
) external virtual override nonReentrant {
for (uint256 i = 0; i < actualIds.length; i++) {
if (futureToken.ownerOf(actualIds[i]) != _msgSender()) {
Expand All @@ -110,7 +114,8 @@ contract TokenTableUnlockerV2 is

function delegateClaim(
uint256[] calldata actualIds,
uint256 batchId
uint256 batchId,
bytes[] calldata
) external virtual override nonReentrant {
if (_msgSender() != claimingDelegate) revert NotPermissioned();
for (uint256 i = 0; i < actualIds.length; i++) {
Expand All @@ -122,7 +127,8 @@ contract TokenTableUnlockerV2 is
function cancel(
uint256[] calldata actualIds,
bool[] calldata shouldWipeClaimableBalance,
uint256 batchId
uint256 batchId,
bytes[] calldata
)
external
virtual
Expand Down
30 changes: 22 additions & 8 deletions contracts/interfaces/ITokenTableUnlockerV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,13 @@ abstract contract ITokenTableUnlockerV2 is IOwnable, IVersionable {
* @param presetIds These IDs can be the hashes of a plaintext preset names but really there is no restriction. Will revert if they already exist.
* @param presets An array of `Preset` structs.
* @param batchId Emitted as an event reserved for EthSign frontend use. This parameter has no effect on contract execution.
* @param extraData An ERC-5750-esque parameter that's passed to the hook directly.
*/
function createPresets(
bytes32[] calldata presetIds,
Preset[] memory presets,
uint256 batchId
Preset[] calldata presets,
uint256 batchId,
bytes[] calldata extraData
) external virtual;

/**
Expand All @@ -101,43 +103,53 @@ abstract contract ITokenTableUnlockerV2 is IOwnable, IVersionable {
* @param actuals An array of `Actual` structs.
* @param recipientIds Emitted as an event reserved for EthSign frontend use. This parameter has no effect on contract execution.
* @param batchId Emitted as an event reserved for EthSign frontend use. This parameter has no effect on contract execution.
* @param extraData An ERC-5750-esque parameter that's passed to the hook directly.
*/
function createActuals(
address[] calldata recipients,
Actual[] memory actuals,
Actual[] calldata actuals,
uint256[] calldata recipientIds,
uint256 batchId
uint256 batchId,
bytes[] calldata extraData
) external virtual;

/**
* @notice Withdraws existing deposit from the contract.
* @dev Emits `TokensWithdrawn`. Only callable by the owner.
* @param amount Amount of deposited funds the founder wishes to withdraw.
* @param extraData An ERC-5750-esque parameter that's passed to the hook directly.
*/
function withdrawDeposit(uint256 amount) external virtual;
function withdrawDeposit(
uint256 amount,
bytes calldata extraData
) external virtual;

/**
* @notice Claims claimable tokens for the specified schedules to the specified addresses respectively.
* @dev Emits `TokensClaimed`. Only callable by the FutureToken owner.
* @param actualIds The IDs of the unlocking schedules that we are trying to claim from.
* @param claimTos If we want to send the claimed tokens to an address other than the caller. To send the claimed tokens to the caller (default behavior), pass in `ethers.constants.AddressZero`.
* @param batchId Emitted as an event reserved for EthSign frontend use. This parameter has no effect on contract execution.
* @param extraData An ERC-5750-esque parameter that's passed to the hook directly.
*/
function claim(
uint256[] calldata actualIds,
address[] calldata claimTos,
uint256 batchId
uint256 batchId,
bytes[] calldata extraData
) external virtual;

/**
* @notice Claims claimable tokens for the specified schedules on behalf of recipients. Claimed tokens are sent to the schedule recipients.
* @dev Emits `TokensClaimed`. Only callable by the claiming delegate.
* @param actualIds The IDs of the unlocking schedules that we are trying to claim from on behalf of the recipients.
* @param batchId Emitted as an event reserved for EthSign frontend use. This parameter has no effect on contract execution.
* @param extraData An ERC-5750-esque parameter that's passed to the hook directly.
*/
function delegateClaim(
uint256[] calldata actualIds,
uint256 batchId
uint256 batchId,
bytes[] calldata extraData
) external virtual;

/**
Expand All @@ -146,12 +158,14 @@ abstract contract ITokenTableUnlockerV2 is IOwnable, IVersionable {
* @param actualIds The ID of the actual unlocking schedule that we want to cancel.
* @param shouldWipeClaimableBalance If the unlocked and claimable balance of the canceled schedule should be wiped. This is usually used to delete an erroneously created schedule that has already started unlocking.
* @param batchId Emitted as an event reserved for EthSign frontend use. This parameter has no effect on contract execution.
* @param extraData An ERC-5750-esque parameter that's passed to the hook directly.
* @return pendingAmountClaimables Number of tokens eligible to be claimed by the affected stakeholders at the moment of cancellation.
*/
function cancel(
uint256[] calldata actualIds,
bool[] calldata shouldWipeClaimableBalance,
uint256 batchId
uint256 batchId,
bytes[] calldata extraData
) external virtual returns (uint256[] memory pendingAmountClaimables);

/**
Expand Down
Loading

0 comments on commit e853d74

Please sign in to comment.