-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #686 from sablier-labs/feat/emit-metadata
feat: emit metadata in `_afterTokenTransfer` hook
- Loading branch information
Showing
19 changed files
with
155 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
test/integration/concrete/lockup/transfer-from/transferFrom.t.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity >=0.8.19 <0.9.0; | ||
|
||
import { Errors } from "src/libraries/Errors.sol"; | ||
|
||
import { Lockup_Integration_Shared_Test } from "../../../shared/lockup/Lockup.t.sol"; | ||
import { Integration_Test } from "../../../Integration.t.sol"; | ||
|
||
abstract contract TransferFrom_Integration_Concrete_Test is Integration_Test, Lockup_Integration_Shared_Test { | ||
function setUp() public virtual override(Integration_Test, Lockup_Integration_Shared_Test) { | ||
changePrank({ msgSender: users.recipient }); | ||
} | ||
|
||
function test_RevertGiven_StreamNotTransferable() external { | ||
uint256 notTransferableStreamId = createDefaultStreamNotTransferable(); | ||
vm.expectRevert( | ||
abi.encodeWithSelector(Errors.SablierV2Lockup_NotTransferrable.selector, notTransferableStreamId) | ||
); | ||
lockup.transferFrom({ from: users.recipient, to: users.alice, tokenId: notTransferableStreamId }); | ||
} | ||
|
||
modifier givenStreamTransferable() { | ||
_; | ||
} | ||
|
||
function test_TransferFrom() external givenStreamTransferable { | ||
// Create a stream. | ||
uint256 streamId = createDefaultStream(); | ||
|
||
// Expect the relevant events to be emitted. | ||
vm.expectEmit({ emitter: address(lockup) }); | ||
emit Transfer({ from: users.recipient, to: users.alice, tokenId: streamId }); | ||
vm.expectEmit({ emitter: address(lockup) }); | ||
emit MetadataUpdate({ _tokenId: streamId }); | ||
|
||
// Transfer the NFT. | ||
lockup.transferFrom({ from: users.recipient, to: users.alice, tokenId: streamId }); | ||
|
||
// Assert that Alice is the new stream recipient (and NFT owner). | ||
address actualRecipient = lockup.getRecipient(streamId); | ||
address expectedRecipient = users.alice; | ||
assertEq(actualRecipient, expectedRecipient, "recipient"); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
test/integration/concrete/lockup/transfer-from/transferFrom.tree
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
transferFrom.t.sol | ||
├── given the stream is not transferable | ||
│ └── it should revert | ||
└── given the stream is transferable | ||
├── it should transfer the NFT | ||
├── it should emit a {Transfer} event | ||
└── it should emit a {MetadataUpdate} event |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.