Skip to content

Commit

Permalink
refactor: make nftDescriptor public (#796)
Browse files Browse the repository at this point in the history
test: nftDescriptor in constructor
  • Loading branch information
andreivladbrg committed Feb 12, 2024
1 parent f695d6a commit 65b2be6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/abstracts/SablierV2Lockup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,8 @@ abstract contract SablierV2Lockup is
/// @inheritdoc ISablierV2Lockup
uint256 public override nextStreamId;

/*//////////////////////////////////////////////////////////////////////////
INTERNAL STORAGE
//////////////////////////////////////////////////////////////////////////*/

/// @dev Contract that generates the non-fungible token URI.
ISablierV2NFTDescriptor internal _nftDescriptor;
/// @inheritdoc ISablierV2Lockup
ISablierV2NFTDescriptor public override nftDescriptor;

/*//////////////////////////////////////////////////////////////////////////
CONSTRUCTOR
Expand All @@ -50,7 +46,7 @@ abstract contract SablierV2Lockup is
)
SablierV2Base(initialAdmin, initialComptroller)
{
_nftDescriptor = initialNFTDescriptor;
nftDescriptor = initialNFTDescriptor;
}

/*//////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -111,7 +107,7 @@ abstract contract SablierV2Lockup is
_requireMinted({ tokenId: streamId });

// Generate the URI describing the stream NFT.
uri = _nftDescriptor.tokenURI({ sablier: this, streamId: streamId });
uri = nftDescriptor.tokenURI({ sablier: this, streamId: streamId });
}

/// @inheritdoc ISablierV2Lockup
Expand Down Expand Up @@ -215,8 +211,8 @@ abstract contract SablierV2Lockup is
/// @inheritdoc ISablierV2Lockup
function setNFTDescriptor(ISablierV2NFTDescriptor newNFTDescriptor) external override onlyAdmin {
// Effects: set the NFT descriptor.
ISablierV2NFTDescriptor oldNftDescriptor = _nftDescriptor;
_nftDescriptor = newNFTDescriptor;
ISablierV2NFTDescriptor oldNftDescriptor = nftDescriptor;
nftDescriptor = newNFTDescriptor;

// Log the change of the NFT descriptor.
emit ISablierV2Lockup.SetNFTDescriptor({
Expand Down
3 changes: 3 additions & 0 deletions src/interfaces/ISablierV2Lockup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ interface ISablierV2Lockup is
/// @notice Counter for stream ids, used in the create functions.
function nextStreamId() external view returns (uint256);

/// @notice Contract that generates the non-fungible token URI.
function nftDescriptor() external view returns (ISablierV2NFTDescriptor);

/// @notice Calculates the amount that the sender would be refunded if the stream were canceled, denoted in units
/// of the asset's decimals.
/// @dev Reverts if `streamId` references a null stream.
Expand Down
4 changes: 4 additions & 0 deletions test/integration/concrete/lockup-dynamic/constructor.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ contract Constructor_LockupDynamic_Integration_Concrete_Test is LockupDynamic_In
uint256 expectedStreamId = 1;
assertEq(actualStreamId, expectedStreamId, "nextStreamId");

address actualNFTDescriptor = address(constructedLockupDynamic.nftDescriptor());
address expectedNFTDescriptor = address(nftDescriptor);
assertEq(actualNFTDescriptor, expectedNFTDescriptor, "nftDescriptor");

// {SablierV2LockupDynamic.constructor}
uint256 actualMaxSegmentCount = constructedLockupDynamic.MAX_SEGMENT_COUNT();
uint256 expectedMaxSegmentCount = defaults.MAX_SEGMENT_COUNT();
Expand Down
4 changes: 4 additions & 0 deletions test/integration/concrete/lockup-linear/constructor.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,9 @@ contract Constructor_LockupLinear_Integration_Concrete_Test is LockupLinear_Inte
uint256 actualStreamId = constructedLockupLinear.nextStreamId();
uint256 expectedStreamId = 1;
assertEq(actualStreamId, expectedStreamId, "nextStreamId");

address actualNFTDescriptor = address(constructedLockupLinear.nftDescriptor());
address expectedNFTDescriptor = address(nftDescriptor);
assertEq(actualNFTDescriptor, expectedNFTDescriptor, "nftDescriptor");
}
}

0 comments on commit 65b2be6

Please sign in to comment.