Skip to content

Commit

Permalink
refactor: rename params to baseParams when referring to ConstructorPa…
Browse files Browse the repository at this point in the history
…rams struct
  • Loading branch information
smol-ninja committed Jan 30, 2024
1 parent bbf6366 commit 712c24c
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 41 deletions.
4 changes: 2 additions & 2 deletions script/CreateMerkleStreamerLL.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { MerkleStreamer } from "../src/types/DataTypes.sol";

contract CreateMerkleStreamerLL is BaseScript {
struct Params {
MerkleStreamer.ConstructorParams constructorParams;
MerkleStreamer.ConstructorParams baseParams;
ISablierV2LockupLinear lockupLinear;
LockupLinear.Durations streamDurations;
string ipfsCID;
Expand All @@ -29,7 +29,7 @@ contract CreateMerkleStreamerLL is BaseScript {
returns (ISablierV2MerkleStreamerLL merkleStreamerLL)
{
merkleStreamerLL = merkleStreamerFactory.createMerkleStreamerLL(
params.constructorParams,
params.baseParams,
params.lockupLinear,
params.streamDurations,
params.ipfsCID,
Expand Down
20 changes: 10 additions & 10 deletions src/SablierV2MerkleStreamerFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ contract SablierV2MerkleStreamerFactory is ISablierV2MerkleStreamerFactory {

/// @notice inheritdoc ISablierV2MerkleStreamerFactory
function createMerkleStreamerLL(
MerkleStreamer.ConstructorParams memory params,
MerkleStreamer.ConstructorParams memory baseParams,
ISablierV2LockupLinear lockupLinear,
LockupLinear.Durations memory streamDurations,
string memory ipfsCID,
Expand All @@ -31,24 +31,24 @@ contract SablierV2MerkleStreamerFactory is ISablierV2MerkleStreamerFactory {
// Hash the parameters to generate a salt.
bytes32 salt = keccak256(
abi.encodePacked(
params.initialAdmin,
params.asset,
bytes32(abi.encodePacked(params.name)),
params.merkleRoot,
params.expiration,
params.cancelable,
params.transferable,
baseParams.initialAdmin,
baseParams.asset,
bytes32(abi.encodePacked(baseParams.name)),
baseParams.merkleRoot,
baseParams.expiration,
baseParams.cancelable,
baseParams.transferable,
lockupLinear,
abi.encode(streamDurations)
)
);

// Deploy the Merkle streamer with CREATE2.
merkleStreamerLL = new SablierV2MerkleStreamerLL{ salt: salt }(params, lockupLinear, streamDurations);
merkleStreamerLL = new SablierV2MerkleStreamerLL{ salt: salt }(baseParams, lockupLinear, streamDurations);

// Using a different function to emit the event to avoid stack too deep error.
emit CreateMerkleStreamerLL(
merkleStreamerLL, params, lockupLinear, streamDurations, ipfsCID, aggregateAmount, recipientsCount
merkleStreamerLL, baseParams, lockupLinear, streamDurations, ipfsCID, aggregateAmount, recipientsCount
);
}
}
4 changes: 2 additions & 2 deletions src/SablierV2MerkleStreamerLL.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ contract SablierV2MerkleStreamerLL is
/// @dev Constructs the contract by initializing the immutable state variables, and max approving the Sablier
/// contract.
constructor(
MerkleStreamer.ConstructorParams memory params,
MerkleStreamer.ConstructorParams memory baseParams,
ISablierV2LockupLinear lockupLinear,
LockupLinear.Durations memory streamDurations_
)
SablierV2MerkleStreamer(params)
SablierV2MerkleStreamer(baseParams)
{
LOCKUP_LINEAR = lockupLinear;
streamDurations = streamDurations_;
Expand Down
6 changes: 3 additions & 3 deletions src/interfaces/ISablierV2MerkleStreamerFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface ISablierV2MerkleStreamerFactory {
/// @notice Emitted when a Sablier V2 Lockup Linear Merkle streamer is created.
event CreateMerkleStreamerLL(
ISablierV2MerkleStreamerLL indexed merkleStreamerLL,
MerkleStreamer.ConstructorParams indexed constructorParams,
MerkleStreamer.ConstructorParams indexed baseParams,
ISablierV2LockupLinear lockupLinear,
LockupLinear.Durations streamDurations,
string ipfsCID,
Expand All @@ -31,7 +31,7 @@ interface ISablierV2MerkleStreamerFactory {

/// @notice Creates a new Merkle streamer that uses Lockup Linear.
/// @dev Emits a {CreateMerkleStreamerLL} event.
/// @param params Struct encapsulating the {SablierV2MerkleStreamer} parameters, which are documented in
/// @param baseParams Struct encapsulating the {SablierV2MerkleStreamer} parameters, which are documented in
/// {DataTypes}.
/// @param lockupLinear The address of the {SablierV2LockupLinear} contract.
/// @param streamDurations The durations for each stream due to the recipient.
Expand All @@ -40,7 +40,7 @@ interface ISablierV2MerkleStreamerFactory {
/// @param recipientsCount Total number of recipients eligible to claim.
/// @return merkleStreamerLL The address of the newly created Merkle streamer contract.
function createMerkleStreamerLL(
MerkleStreamer.ConstructorParams memory params,
MerkleStreamer.ConstructorParams memory baseParams,
ISablierV2LockupLinear lockupLinear,
LockupLinear.Durations memory streamDurations,
string memory ipfsCID,
Expand Down
2 changes: 1 addition & 1 deletion test/Base.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ abstract contract Base_Test is DeployOptimized, Events, Merkle, V2CoreAssertions
returns (bytes memory)
{
bytes memory constructorArgs =
abi.encode(defaults.constructorParams(admin, merkleRoot, expiration), lockupLinear, defaults.durations());
abi.encode(defaults.baseParams(admin, merkleRoot, expiration), lockupLinear, defaults.durations());
if (!isTestOptimizedProfile()) {
return bytes.concat(type(SablierV2MerkleStreamerLL).creationCode, constructorArgs);
} else {
Expand Down
13 changes: 5 additions & 8 deletions test/fork/merkle-streamer/MerkleStreamerLL.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ abstract contract MerkleStreamerLL_Fork_Test is Fork_Test {
uint256 aggregateAmount;
uint128 clawbackAmount;
address expectedStreamerLL;
MerkleStreamer.ConstructorParams constructorParams;
MerkleStreamer.ConstructorParams baseParams;
LockupLinear.Stream expectedStream;
uint256 expectedStreamId;
uint256[] indexes;
Expand Down Expand Up @@ -93,16 +93,13 @@ abstract contract MerkleStreamerLL_Fork_Test is Fork_Test {

vars.expectedStreamerLL = computeMerkleStreamerLLAddress(params.admin, vars.merkleRoot, params.expiration);

vars.constructorParams = defaults.constructorParams({
admin: params.admin,
merkleRoot: vars.merkleRoot,
expiration: params.expiration
});
vars.baseParams =
defaults.baseParams({ admin: params.admin, merkleRoot: vars.merkleRoot, expiration: params.expiration });

vm.expectEmit({ emitter: address(merkleStreamerFactory) });
emit CreateMerkleStreamerLL({
merkleStreamerLL: ISablierV2MerkleStreamerLL(vars.expectedStreamerLL),
constructorParams: vars.constructorParams,
baseParams: vars.baseParams,
lockupLinear: lockupLinear,
streamDurations: defaults.durations(),
ipfsCID: defaults.IPFS_CID(),
Expand All @@ -111,7 +108,7 @@ abstract contract MerkleStreamerLL_Fork_Test is Fork_Test {
});

vars.merkleStreamerLL = merkleStreamerFactory.createMerkleStreamerLL({
params: vars.constructorParams,
baseParams: vars.baseParams,
lockupLinear: lockupLinear,
streamDurations: defaults.durations(),
ipfsCID: defaults.IPFS_CID(),
Expand Down
2 changes: 1 addition & 1 deletion test/integration/merkle-streamer/MerkleStreamer.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ abstract contract MerkleStreamer_Integration_Test is Integration_Test {

function createMerkleStreamerLL(address admin, uint40 expiration) internal returns (ISablierV2MerkleStreamerLL) {
return merkleStreamerFactory.createMerkleStreamerLL({
params: defaults.constructorParams(admin, defaults.MERKLE_ROOT(), expiration),
baseParams: defaults.baseParams(admin, defaults.MERKLE_ROOT(), expiration),
lockupLinear: lockupLinear,
streamDurations: defaults.durations(),
ipfsCID: defaults.IPFS_CID(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@ contract CreateMerkleStreamerLL_Integration_Test is MerkleStreamer_Integration_T
}

function test_RevertWhen_CampaignNameTooLong() external {
MerkleStreamer.ConstructorParams memory params = defaults.constructorParams();
MerkleStreamer.ConstructorParams memory baseParams = defaults.baseParams();
LockupLinear.Durations memory streamDurations = defaults.durations();
string memory ipfsCID = defaults.IPFS_CID();
uint256 aggregateAmount = defaults.AGGREGATE_AMOUNT();
uint256 recipientsCount = defaults.RECIPIENTS_COUNT();

params.name = "this string is longer than 32 characters";
baseParams.name = "this string is longer than 32 characters";

vm.expectRevert(
abi.encodeWithSelector(
Errors.SablierV2MerkleStreamer_CampaignNameTooLong.selector, bytes(params.name).length, 32
Errors.SablierV2MerkleStreamer_CampaignNameTooLong.selector, bytes(baseParams.name).length, 32
)
);

merkleStreamerFactory.createMerkleStreamerLL({
params: params,
baseParams: baseParams,
lockupLinear: lockupLinear,
streamDurations: streamDurations,
ipfsCID: ipfsCID,
Expand All @@ -45,15 +45,15 @@ contract CreateMerkleStreamerLL_Integration_Test is MerkleStreamer_Integration_T

/// @dev This test works because a default Merkle streamer is deployed in {Integration_Test.setUp}
function test_RevertGiven_AlreadyDeployed() external whenCampaignNameIsNotTooLong {
MerkleStreamer.ConstructorParams memory params = defaults.constructorParams();
MerkleStreamer.ConstructorParams memory baseParams = defaults.baseParams();
LockupLinear.Durations memory streamDurations = defaults.durations();
string memory ipfsCID = defaults.IPFS_CID();
uint256 aggregateAmount = defaults.AGGREGATE_AMOUNT();
uint256 recipientsCount = defaults.RECIPIENTS_COUNT();

vm.expectRevert();
merkleStreamerFactory.createMerkleStreamerLL({
params: params,
baseParams: baseParams,
lockupLinear: lockupLinear,
streamDurations: streamDurations,
ipfsCID: ipfsCID,
Expand All @@ -77,13 +77,13 @@ contract CreateMerkleStreamerLL_Integration_Test is MerkleStreamer_Integration_T
vm.assume(admin != users.admin);
address expectedStreamerLL = computeMerkleStreamerLLAddress(admin, expiration);

MerkleStreamer.ConstructorParams memory constructorParams =
defaults.constructorParams({ admin: admin, merkleRoot: defaults.MERKLE_ROOT(), expiration: expiration });
MerkleStreamer.ConstructorParams memory baseParams =
defaults.baseParams({ admin: admin, merkleRoot: defaults.MERKLE_ROOT(), expiration: expiration });

vm.expectEmit({ emitter: address(merkleStreamerFactory) });
emit CreateMerkleStreamerLL({
merkleStreamerLL: ISablierV2MerkleStreamerLL(expectedStreamerLL),
constructorParams: constructorParams,
baseParams: baseParams,
lockupLinear: lockupLinear,
streamDurations: defaults.durations(),
ipfsCID: defaults.IPFS_CID(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ contract Constructor_MerkleStreamerLL_Integration_Test is MerkleStreamer_Integra

function test_Constructor() external {
SablierV2MerkleStreamerLL constructedStreamerLL =
new SablierV2MerkleStreamerLL(defaults.constructorParams(), lockupLinear, defaults.durations());
new SablierV2MerkleStreamerLL(defaults.baseParams(), lockupLinear, defaults.durations());

Vars memory vars;

Expand Down
6 changes: 3 additions & 3 deletions test/utils/Defaults.sol
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ contract Defaults is Merkle {
return getProof(LEAVES.toBytes32(), pos);
}

function constructorParams() public view returns (MerkleStreamer.ConstructorParams memory) {
return constructorParams(users.admin, MERKLE_ROOT, EXPIRATION);
function baseParams() public view returns (MerkleStreamer.ConstructorParams memory) {
return baseParams(users.admin, MERKLE_ROOT, EXPIRATION);
}

function constructorParams(
function baseParams(
address admin,
bytes32 merkleRoot,
uint40 expiration
Expand Down
2 changes: 1 addition & 1 deletion test/utils/Events.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ abstract contract Events {
event Clawback(address indexed admin, address indexed to, uint128 amount);
event CreateMerkleStreamerLL(
ISablierV2MerkleStreamerLL indexed merkleStreamerLL,
MerkleStreamer.ConstructorParams indexed constructorParams,
MerkleStreamer.ConstructorParams indexed baseParams,
ISablierV2LockupLinear lockupLinear,
LockupLinear.Durations streamDurations,
string ipfsCID,
Expand Down

0 comments on commit 712c24c

Please sign in to comment.