Skip to content

Commit

Permalink
feat: store ipfsCID as a public variable
Browse files Browse the repository at this point in the history
  • Loading branch information
smol-ninja committed Feb 10, 2024
1 parent dd1f751 commit 2d83282
Show file tree
Hide file tree
Showing 17 changed files with 29 additions and 34 deletions.
3 changes: 1 addition & 2 deletions script/CreateMerkleLockupLD.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ contract CreateMerkleLockupLD is BaseScript {
struct Params {
MerkleLockup.ConstructorParams baseParams;
ISablierV2LockupDynamic lockupDynamic;
string ipfsCID;
uint256 campaignTotalAmount;
uint256 recipientsCount;
}
Expand All @@ -27,7 +26,7 @@ contract CreateMerkleLockupLD is BaseScript {
returns (ISablierV2MerkleLockupLD merkleLockupLD)
{
merkleLockupLD = merkleLockupFactory.createMerkleLockupLD(
params.baseParams, params.lockupDynamic, params.ipfsCID, params.campaignTotalAmount, params.recipientsCount
params.baseParams, params.lockupDynamic, params.campaignTotalAmount, params.recipientsCount
);
}
}
2 changes: 0 additions & 2 deletions script/CreateMerkleLockupLL.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ contract CreateMerkleLockupLL is BaseScript {
MerkleLockup.ConstructorParams baseParams;
ISablierV2LockupLinear lockupLinear;
LockupLinear.Durations streamDurations;
string ipfsCID;
uint256 campaignTotalAmount;
uint256 recipientsCount;
}
Expand All @@ -32,7 +31,6 @@ contract CreateMerkleLockupLL is BaseScript {
params.baseParams,
params.lockupLinear,
params.streamDurations,
params.ipfsCID,
params.campaignTotalAmount,
params.recipientsCount
);
Expand Down
8 changes: 4 additions & 4 deletions src/SablierV2MerkleLockupFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ contract SablierV2MerkleLockupFactory is ISablierV2MerkleLockupFactory {
function createMerkleLockupLD(
MerkleLockup.ConstructorParams memory baseParams,
ISablierV2LockupDynamic lockupDynamic,
string memory ipfsCID,
uint256 aggregateAmount,
uint256 recipientsCount
)
Expand All @@ -35,6 +34,7 @@ contract SablierV2MerkleLockupFactory is ISablierV2MerkleLockupFactory {
abi.encodePacked(
baseParams.initialAdmin,
baseParams.asset,
abi.encode(baseParams.ipfsCID),
bytes32(abi.encodePacked(baseParams.name)),
baseParams.merkleRoot,
baseParams.expiration,
Expand All @@ -48,15 +48,14 @@ contract SablierV2MerkleLockupFactory is ISablierV2MerkleLockupFactory {
merkleLockupLD = new SablierV2MerkleLockupLD{ salt: salt }(baseParams, lockupDynamic);

// Using a different function to emit the event to avoid stack too deep error.
emit CreateMerkleLockupLD(merkleLockupLD, baseParams, lockupDynamic, ipfsCID, aggregateAmount, recipientsCount);
emit CreateMerkleLockupLD(merkleLockupLD, baseParams, lockupDynamic, aggregateAmount, recipientsCount);
}

/// @notice inheritdoc ISablierV2MerkleLockupFactory
function createMerkleLockupLL(
MerkleLockup.ConstructorParams memory baseParams,
ISablierV2LockupLinear lockupLinear,
LockupLinear.Durations memory streamDurations,
string memory ipfsCID,
uint256 aggregateAmount,
uint256 recipientsCount
)
Expand All @@ -68,6 +67,7 @@ contract SablierV2MerkleLockupFactory is ISablierV2MerkleLockupFactory {
abi.encodePacked(
baseParams.initialAdmin,
baseParams.asset,
abi.encode(baseParams.ipfsCID),
bytes32(abi.encodePacked(baseParams.name)),
baseParams.merkleRoot,
baseParams.expiration,
Expand All @@ -83,7 +83,7 @@ contract SablierV2MerkleLockupFactory is ISablierV2MerkleLockupFactory {

// Using a different function to emit the event to avoid stack too deep error.
emit CreateMerkleLockupLL(
merkleLockupLL, baseParams, lockupLinear, streamDurations, ipfsCID, aggregateAmount, recipientsCount
merkleLockupLL, baseParams, lockupLinear, streamDurations, aggregateAmount, recipientsCount
);
}
}
4 changes: 4 additions & 0 deletions src/abstracts/SablierV2MerkleLockup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ abstract contract SablierV2MerkleLockup is
/// @inheritdoc ISablierV2MerkleLockup
bool public immutable override TRANSFERABLE;

/// @inheritdoc ISablierV2MerkleLockup
string public ipfsCID;

/// @dev Packed booleans that record the history of claims.
BitMaps.BitMap internal _claimedBitMap;

Expand All @@ -63,6 +66,7 @@ abstract contract SablierV2MerkleLockup is
ASSET = params.asset;
CANCELABLE = params.cancelable;
EXPIRATION = params.expiration;
ipfsCID = params.ipfsCID;
MERKLE_ROOT = params.merkleRoot;
NAME = bytes32(abi.encodePacked(params.name));
TRANSFERABLE = params.transferable;
Expand Down
3 changes: 3 additions & 0 deletions src/interfaces/ISablierV2MerkleLockup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ interface ISablierV2MerkleLockup is IAdminable {
/// @dev This is an immutable state variable.
function EXPIRATION() external returns (uint40);

/// @notice The content identifier for indexing the contract on IPFS.
function ipfsCID() external view returns (string memory);

/// @notice Retrieves the name of the campaign.
function name() external returns (string memory);

Expand Down
8 changes: 0 additions & 8 deletions src/interfaces/ISablierV2MerkleLockupFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@ interface ISablierV2MerkleLockupFactory {
/// @param baseParams Struct encapsulating the {SablierV2MerkleLockup} parameters, which are documented in
/// {DataTypes}.
/// @param lockupDynamic The address of the {SablierV2LockupDynamic} contract.
/// @param ipfsCID Metadata parameter emitted for indexing purposes.
/// @param aggregateAmount Total amount of ERC-20 assets to be streamed to all recipients.
/// @param recipientsCount Total number of recipients eligible to claim.
event CreateMerkleLockupLD(
ISablierV2MerkleLockupLD indexed merkleLockupLD,
MerkleLockup.ConstructorParams indexed baseParams,
ISablierV2LockupDynamic lockupDynamic,
string ipfsCID,
uint256 aggregateAmount,
uint256 recipientsCount
);
Expand All @@ -39,15 +37,13 @@ interface ISablierV2MerkleLockupFactory {
/// {DataTypes}.
/// @param lockupLinear The address of the {SablierV2LockupLinear} contract.
/// @param streamDurations The durations for each stream due to the recipient.
/// @param ipfsCID Metadata parameter emitted for indexing purposes.
/// @param aggregateAmount Total amount of ERC-20 assets to be streamed to all recipients.
/// @param recipientsCount Total number of recipients eligible to claim.
event CreateMerkleLockupLL(
ISablierV2MerkleLockupLL indexed merkleLockupLL,
MerkleLockup.ConstructorParams indexed baseParams,
ISablierV2LockupLinear lockupLinear,
LockupLinear.Durations streamDurations,
string ipfsCID,
uint256 aggregateAmount,
uint256 recipientsCount
);
Expand All @@ -61,14 +57,12 @@ interface ISablierV2MerkleLockupFactory {
/// @param baseParams Struct encapsulating the {SablierV2MerkleLockup} parameters, which are documented in
/// {DataTypes}.
/// @param lockupDynamic The address of the {SablierV2LockupDynamic} contract.
/// @param ipfsCID Metadata parameter emitted for indexing purposes.
/// @param aggregateAmount Total amount of ERC-20 assets to be streamed to all recipients.
/// @param recipientsCount Total number of recipients eligible to claim.
/// @return merkleLockupLD The address of the newly created Merkle Lockup Dynamic contract.
function createMerkleLockupLD(
MerkleLockup.ConstructorParams memory baseParams,
ISablierV2LockupDynamic lockupDynamic,
string memory ipfsCID,
uint256 aggregateAmount,
uint256 recipientsCount
)
Expand All @@ -81,15 +75,13 @@ interface ISablierV2MerkleLockupFactory {
/// {DataTypes}.
/// @param lockupLinear The address of the {SablierV2LockupLinear} contract.
/// @param streamDurations The durations for each stream due to the recipient.
/// @param ipfsCID Metadata parameter emitted for indexing purposes.
/// @param aggregateAmount Total amount of ERC-20 assets to be streamed to all recipients.
/// @param recipientsCount Total number of recipients eligible to claim.
/// @return merkleLockupLL The address of the newly created Merkle Lockup Linear contract.
function createMerkleLockupLL(
MerkleLockup.ConstructorParams memory baseParams,
ISablierV2LockupLinear lockupLinear,
LockupLinear.Durations memory streamDurations,
string memory ipfsCID,
uint256 aggregateAmount,
uint256 recipientsCount
)
Expand Down
2 changes: 2 additions & 0 deletions src/types/DataTypes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ library MerkleLockup {
/// @notice Struct encapsulating the base constructor parameter of a {SablierV2MerkleLockup} contract.
/// @param initialAdmin The initial admin of the Merkle Lockup contract.
/// @param asset The address of the streamed ERC-20 asset.
/// @param ipfsCID The content identifier for indexing the contract on IPFS.
/// @param name The name of the campaign.
/// @param merkleRoot The Merkle root of the claim data.
/// @param expiration The expiration of the streaming campaign, as a Unix timestamp.
Expand All @@ -74,6 +75,7 @@ library MerkleLockup {
struct ConstructorParams {
address initialAdmin;
IERC20 asset;
string ipfsCID;
string name;
bytes32 merkleRoot;
uint40 expiration;
Expand Down
2 changes: 2 additions & 0 deletions test/Base.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ abstract contract Base_Test is DeployOptimized, Events, Merkle, V2CoreAssertions
abi.encodePacked(
admin,
asset,
abi.encode(defaults.IPFS_CID()),
defaults.NAME_BYTES32(),
merkleRoot,
expiration,
Expand Down Expand Up @@ -316,6 +317,7 @@ abstract contract Base_Test is DeployOptimized, Events, Merkle, V2CoreAssertions
abi.encodePacked(
admin,
asset,
abi.encode(defaults.IPFS_CID()),
defaults.NAME_BYTES32(),
merkleRoot,
expiration,
Expand Down
2 changes: 0 additions & 2 deletions test/fork/merkle-lockup/MerkleLockupLD.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,13 @@ abstract contract MerkleLockupLD_Fork_Test is Fork_Test {
merkleLockupLD: ISablierV2MerkleLockupLD(vars.expectedLockupLD),
baseParams: vars.baseParams,
lockupDynamic: lockupDynamic,
ipfsCID: defaults.IPFS_CID(),
aggregateAmount: vars.aggregateAmount,
recipientsCount: vars.recipientsCount
});

vars.merkleLockupLD = merkleLockupFactory.createMerkleLockupLD({
baseParams: vars.baseParams,
lockupDynamic: lockupDynamic,
ipfsCID: defaults.IPFS_CID(),
aggregateAmount: vars.aggregateAmount,
recipientsCount: vars.recipientsCount
});
Expand Down
2 changes: 0 additions & 2 deletions test/fork/merkle-lockup/MerkleLockupLL.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ abstract contract MerkleLockupLL_Fork_Test is Fork_Test {
baseParams: vars.baseParams,
lockupLinear: lockupLinear,
streamDurations: defaults.durations(),
ipfsCID: defaults.IPFS_CID(),
aggregateAmount: vars.aggregateAmount,
recipientsCount: vars.recipientsCount
});
Expand All @@ -111,7 +110,6 @@ abstract contract MerkleLockupLL_Fork_Test is Fork_Test {
baseParams: vars.baseParams,
lockupLinear: lockupLinear,
streamDurations: defaults.durations(),
ipfsCID: defaults.IPFS_CID(),
aggregateAmount: vars.aggregateAmount,
recipientsCount: vars.recipientsCount
});
Expand Down
2 changes: 0 additions & 2 deletions test/integration/merkle-lockup/MerkleLockup.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ abstract contract MerkleLockup_Integration_Test is Integration_Test {
return merkleLockupFactory.createMerkleLockupLD({
baseParams: defaults.baseParams(admin, defaults.MERKLE_ROOT_LD(), expiration),
lockupDynamic: lockupDynamic,
ipfsCID: defaults.IPFS_CID(),
aggregateAmount: defaults.AGGREGATE_AMOUNT(),
recipientsCount: defaults.RECIPIENTS_COUNT()
});
Expand Down Expand Up @@ -117,7 +116,6 @@ abstract contract MerkleLockup_Integration_Test is Integration_Test {
baseParams: defaults.baseParams(admin, defaults.MERKLE_ROOT_LL(), expiration),
lockupLinear: lockupLinear,
streamDurations: defaults.durations(),
ipfsCID: defaults.IPFS_CID(),
aggregateAmount: defaults.AGGREGATE_AMOUNT(),
recipientsCount: defaults.RECIPIENTS_COUNT()
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ contract CreateMerkleLockupLD_Integration_Test is MerkleLockup_Integration_Test

function test_RevertWhen_CampaignNameTooLong() external {
MerkleLockup.ConstructorParams memory baseParams = defaults.baseParamsLD();
string memory ipfsCID = defaults.IPFS_CID();
uint256 aggregateAmount = defaults.AGGREGATE_AMOUNT();
uint256 recipientsCount = defaults.RECIPIENTS_COUNT();

Expand All @@ -29,7 +28,6 @@ contract CreateMerkleLockupLD_Integration_Test is MerkleLockup_Integration_Test
merkleLockupFactory.createMerkleLockupLD({
baseParams: baseParams,
lockupDynamic: lockupDynamic,
ipfsCID: ipfsCID,
aggregateAmount: aggregateAmount,
recipientsCount: recipientsCount
});
Expand All @@ -42,15 +40,13 @@ contract CreateMerkleLockupLD_Integration_Test is MerkleLockup_Integration_Test
/// @dev This test works because a default Merkle Lockup contract is deployed in {Integration_Test.setUp}
function test_RevertGiven_AlreadyCreated() external whenCampaignNameIsNotTooLong {
MerkleLockup.ConstructorParams memory baseParams = defaults.baseParamsLD();
string memory ipfsCID = defaults.IPFS_CID();
uint256 aggregateAmount = defaults.AGGREGATE_AMOUNT();
uint256 recipientsCount = defaults.RECIPIENTS_COUNT();

vm.expectRevert();
merkleLockupFactory.createMerkleLockupLD({
baseParams: baseParams,
lockupDynamic: lockupDynamic,
ipfsCID: ipfsCID,
aggregateAmount: aggregateAmount,
recipientsCount: recipientsCount
});
Expand Down Expand Up @@ -79,7 +75,6 @@ contract CreateMerkleLockupLD_Integration_Test is MerkleLockup_Integration_Test
merkleLockupLD: ISablierV2MerkleLockupLD(expectedLockupLD),
baseParams: baseParams,
lockupDynamic: lockupDynamic,
ipfsCID: defaults.IPFS_CID(),
aggregateAmount: defaults.AGGREGATE_AMOUNT(),
recipientsCount: defaults.RECIPIENTS_COUNT()
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ contract CreateMerkleLockupLL_Integration_Test is MerkleLockup_Integration_Test
function test_RevertWhen_CampaignNameTooLong() external {
MerkleLockup.ConstructorParams memory baseParams = defaults.baseParamsLL();
LockupLinear.Durations memory streamDurations = defaults.durations();
string memory ipfsCID = defaults.IPFS_CID();
uint256 aggregateAmount = defaults.AGGREGATE_AMOUNT();
uint256 recipientsCount = defaults.RECIPIENTS_COUNT();

Expand All @@ -33,7 +32,6 @@ contract CreateMerkleLockupLL_Integration_Test is MerkleLockup_Integration_Test
baseParams: baseParams,
lockupLinear: lockupLinear,
streamDurations: streamDurations,
ipfsCID: ipfsCID,
aggregateAmount: aggregateAmount,
recipientsCount: recipientsCount
});
Expand All @@ -47,7 +45,6 @@ contract CreateMerkleLockupLL_Integration_Test is MerkleLockup_Integration_Test
function test_RevertGiven_AlreadyCreated() external whenCampaignNameIsNotTooLong {
MerkleLockup.ConstructorParams memory baseParams = defaults.baseParamsLL();
LockupLinear.Durations memory streamDurations = defaults.durations();
string memory ipfsCID = defaults.IPFS_CID();
uint256 aggregateAmount = defaults.AGGREGATE_AMOUNT();
uint256 recipientsCount = defaults.RECIPIENTS_COUNT();

Expand All @@ -56,7 +53,6 @@ contract CreateMerkleLockupLL_Integration_Test is MerkleLockup_Integration_Test
baseParams: baseParams,
lockupLinear: lockupLinear,
streamDurations: streamDurations,
ipfsCID: ipfsCID,
aggregateAmount: aggregateAmount,
recipientsCount: recipientsCount
});
Expand Down Expand Up @@ -86,7 +82,6 @@ contract CreateMerkleLockupLL_Integration_Test is MerkleLockup_Integration_Test
baseParams: baseParams,
lockupLinear: lockupLinear,
streamDurations: defaults.durations(),
ipfsCID: defaults.IPFS_CID(),
aggregateAmount: defaults.AGGREGATE_AMOUNT(),
recipientsCount: defaults.RECIPIENTS_COUNT()
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ contract Constructor_MerkleLockupLD_Integration_Test is MerkleLockup_Integration
address actualAdmin;
uint256 actualAllowance;
address actualAsset;
string actualIpfsCID;
string actualName;
bool actualCancelable;
bool actualTransferable;
Expand All @@ -22,6 +23,7 @@ contract Constructor_MerkleLockupLD_Integration_Test is MerkleLockup_Integration
address expectedAdmin;
uint256 expectedAllowance;
address expectedAsset;
string expectedIpfsCID;
bytes32 expectedName;
bool expectedCancelable;
bool expectedTransferable;
Expand Down Expand Up @@ -71,5 +73,9 @@ contract Constructor_MerkleLockupLD_Integration_Test is MerkleLockup_Integration
vars.actualAllowance = asset.allowance(address(constructedLockupLD), address(lockupDynamic));
vars.expectedAllowance = MAX_UINT256;
assertEq(vars.actualAllowance, vars.expectedAllowance, "allowance");

vars.actualIpfsCID = constructedLockupLD.ipfsCID();
vars.expectedIpfsCID = defaults.IPFS_CID();
assertEq(vars.actualIpfsCID, vars.expectedIpfsCID, "ipfsCID");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ contract Constructor_MerkleLockupLL_Integration_Test is MerkleLockup_Integration
address actualAdmin;
uint256 actualAllowance;
address actualAsset;
string actualIpfsCID;
string actualName;
bool actualCancelable;
bool actualTransferable;
Expand All @@ -23,6 +24,7 @@ contract Constructor_MerkleLockupLL_Integration_Test is MerkleLockup_Integration
address expectedAdmin;
uint256 expectedAllowance;
address expectedAsset;
string expectedIpfsCID;
bytes32 expectedName;
bool expectedCancelable;
bool expectedTransferable;
Expand Down Expand Up @@ -78,5 +80,9 @@ contract Constructor_MerkleLockupLL_Integration_Test is MerkleLockup_Integration
vars.actualAllowance = asset.allowance(address(constructedLockupLL), address(lockupLinear));
vars.expectedAllowance = MAX_UINT256;
assertEq(vars.actualAllowance, vars.expectedAllowance, "allowance");

vars.actualIpfsCID = constructedLockupLL.ipfsCID();
vars.expectedIpfsCID = defaults.IPFS_CID();
assertEq(vars.actualIpfsCID, vars.expectedIpfsCID, "ipfsCID");
}
}
1 change: 1 addition & 0 deletions test/utils/Defaults.sol
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ contract Defaults is Merkle {
return MerkleLockup.ConstructorParams({
initialAdmin: admin,
asset: asset,
ipfsCID: IPFS_CID,
name: NAME,
merkleRoot: merkleRoot,
expiration: expiration,
Expand Down
Loading

0 comments on commit 2d83282

Please sign in to comment.