Skip to content

Commit

Permalink
process native bucket transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
ququzone committed Mar 14, 2024
1 parent 0e62a24 commit fc5693d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions contracts/VotingEscrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,20 @@ contract VotingEscrow is IVotingEscrow, ReentrancyGuardUpgradeable {

/* TRANSFER FUNCTIONS */

function _adminTransferFrom(address _from, address _to, uint256 _tokenId) internal {
delete idToApprovals[_tokenId];
// Remove NFT. Throws if `_tokenId` is not a valid NFT
_removeTokenFrom(_from, _tokenId);
// Update voting checkpoints
_checkpointDelegator(_tokenId, 0, _to);
// Add NFT
_addTokenTo(_to, _tokenId);
// Set the block of ownership transfer (for Flash NFT protection)
ownershipChange[_tokenId] = block.number;
// Log the transfer
emit Transfer(_from, _to, _tokenId);
}

function _transferFrom(address _from, address _to, uint256 _tokenId, address _sender) internal {
// Check requirements
if (!_isApprovedOrOwner(_sender, _tokenId)) revert NotApprovedOrOwner();
Expand Down Expand Up @@ -922,6 +936,10 @@ contract VotingEscrow is IVotingEscrow, ReentrancyGuardUpgradeable {
_tokenIdNative[_tokenId] = _bucketId;
return _tokenId;
}
address _owner = _ownerOf(_tokenId);
if (_owner != _voter) {
_adminTransferFrom(_owner, _voter, _tokenId);
}

LockedBalance memory oldLocked = _locked[_tokenId];
uint256 unlockTime = (_end / WEEK) * WEEK; // Locktime is rounded down to weeks
Expand Down
Loading

0 comments on commit fc5693d

Please sign in to comment.