Skip to content

Commit

Permalink
Update metadata before hook in cancel function (#727)
Browse files Browse the repository at this point in the history
* fix: update metadata before hook in cancel

* test: update Precompiles bytecode

* chore: improve explanatory comment in dynamic contract

* chore: simplify comments

* test: update Precompiles bytecode

---------

Co-authored-by: Paul Razvan Berg <[email protected]>
  • Loading branch information
andreivladbrg and PaulRBerg committed Dec 15, 2023
1 parent d302524 commit bd2bc9e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/SablierV2LockupDynamic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,9 @@ contract SablierV2LockupDynamic is
// Log the cancellation.
emit ISablierV2Lockup.CancelLockupStream(streamId, sender, recipient, asset, senderAmount, recipientAmount);

// Emits an ERC-4906 event to trigger an update of the NFT metadata.
emit MetadataUpdate({ _tokenId: streamId });

// Interactions: if the recipient is a contract, try to invoke the cancel hook on the recipient without
// reverting if the hook is not implemented, and without bubbling up any potential revert.
if (recipient.code.length > 0) {
Expand Down
3 changes: 3 additions & 0 deletions src/SablierV2LockupLinear.sol
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,9 @@ contract SablierV2LockupLinear is
// Log the cancellation.
emit ISablierV2Lockup.CancelLockupStream(streamId, sender, recipient, asset, senderAmount, recipientAmount);

// Emits an ERC-4906 event to trigger an update of the NFT metadata.
emit MetadataUpdate({ _tokenId: streamId });

// Interactions: if the recipient is a contract, try to invoke the cancel hook on the recipient without
// reverting if the hook is not implemented, and without bubbling up any potential revert.
if (recipient.code.length > 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/abstracts/SablierV2Lockup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ abstract contract SablierV2Lockup is
}

/// @inheritdoc ISablierV2Lockup
function cancel(uint256 streamId) public override noDelegateCall updateMetadata(streamId) {
function cancel(uint256 streamId) public override noDelegateCall {
// Checks: the stream is neither depleted nor canceled. This also checks that the stream is not null.
if (isDepleted(streamId)) {
revert Errors.SablierV2Lockup_StreamDepleted(streamId);
Expand Down
4 changes: 2 additions & 2 deletions test/utils/Precompiles.sol

Large diffs are not rendered by default.

0 comments on commit bd2bc9e

Please sign in to comment.