Skip to content

Commit

Permalink
refactor: alphabetical constructor params
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulRBerg authored and smol-ninja committed Apr 12, 2024
1 parent 7c3ca60 commit 079f432
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion precompiles/Precompiles.sol

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions src/SablierV2MerkleLockupFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ contract SablierV2MerkleLockupFactory is ISablierV2MerkleLockupFactory {
// Hash the parameters to generate a salt.
bytes32 salt = keccak256(
abi.encodePacked(
baseParams.initialAdmin,
baseParams.asset,
baseParams.cancelable,
baseParams.expiration,
baseParams.initialAdmin,
abi.encode(baseParams.ipfsCID),
bytes32(abi.encodePacked(baseParams.name)),
baseParams.merkleRoot,
baseParams.expiration,
baseParams.cancelable,
bytes32(abi.encodePacked(baseParams.name)),
baseParams.transferable,
lockupLinear,
abi.encode(streamDurations)
Expand Down Expand Up @@ -86,13 +86,13 @@ contract SablierV2MerkleLockupFactory is ISablierV2MerkleLockupFactory {
// Hash the parameters to generate a salt.
bytes32 salt = keccak256(
abi.encodePacked(
baseParams.initialAdmin,
baseParams.asset,
baseParams.cancelable,
baseParams.expiration,
baseParams.initialAdmin,
abi.encode(baseParams.ipfsCID),
bytes32(abi.encodePacked(baseParams.name)),
baseParams.merkleRoot,
baseParams.expiration,
baseParams.cancelable,
bytes32(abi.encodePacked(baseParams.name)),
baseParams.transferable,
lockupTranched,
abi.encode(tranchesWithPercentages)
Expand Down
18 changes: 9 additions & 9 deletions src/types/DataTypes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -90,22 +90,22 @@ library BatchLockup {

library MerkleLockup {
/// @notice Struct encapsulating the base constructor parameters of a MerkleLockup campaign.
/// @param initialAdmin The initial admin of the MerkleLockup campaign.
/// @param asset The contract address of the ERC-20 asset to be distributed.
/// @param cancelable Indicates if the stream will be cancelable after claiming.
/// @param expiration The expiration of the campaign, as a Unix timestamp.
/// @param initialAdmin The initial admin of the MerkleLockup campaign.
/// @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 campaign, as a Unix timestamp.
/// @param cancelable Indicates if the stream will be cancelable after claiming.
/// @param name The name of the campaign.
/// @param transferable Indicates if the stream will be transferable after claiming.
struct ConstructorParams {
address initialAdmin;
IERC20 asset;
bool cancelable;
uint40 expiration;
address initialAdmin;
string ipfsCID;
string name;
bytes32 merkleRoot;
uint40 expiration;
bool cancelable;
string name;
bool transferable;
}
}
Expand All @@ -114,7 +114,7 @@ library MerkleLT {
/// @notice Struct encapsulating the unlock percentage and duration of a tranche.
/// @dev Since users may have different amounts allocated, this struct makes it possible to calculate the amounts
/// at claim time. An 18-decimal format is used to represent percentages: 100% = 1e18. For more information, see
/// the PRBMath documentation on {UD2x18}: https://github.com/PaulRBerg/prb-math
/// the PRBMath documentation on UD2x18: https://github.com/PaulRBerg/prb-math
/// @param unlockPercentage The percentage designated to be unlocked in this tranche.
/// @param duration The time difference in seconds between this tranche and the previous one.
struct TrancheWithPercentage {
Expand Down
20 changes: 10 additions & 10 deletions test/Base.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -286,13 +286,13 @@ abstract contract Base_Test is
{
bytes32 salt = keccak256(
abi.encodePacked(
admin,
address(asset_),
defaults.CANCELABLE(),
expiration,
admin,
abi.encode(defaults.IPFS_CID()),
defaults.NAME_BYTES32(),
merkleRoot,
expiration,
defaults.CANCELABLE(),
defaults.NAME_BYTES32(),
defaults.TRANSFERABLE(),
lockupLinear,
abi.encode(defaults.durations())
Expand Down Expand Up @@ -330,13 +330,13 @@ abstract contract Base_Test is
{
bytes32 salt = keccak256(
abi.encodePacked(
admin,
address(asset_),
defaults.CANCELABLE(),
expiration,
admin,
abi.encode(defaults.IPFS_CID()),
defaults.NAME_BYTES32(),
merkleRoot,
expiration,
defaults.CANCELABLE(),
defaults.NAME_BYTES32(),
defaults.TRANSFERABLE(),
lockupTranched,
abi.encode(defaults.tranchesWithPercentages())
Expand All @@ -361,7 +361,7 @@ abstract contract Base_Test is
returns (bytes memory)
{
bytes memory constructorArgs =
abi.encode(defaults.baseParams(admin, asset_, merkleRoot, expiration), lockupLinear, defaults.durations());
abi.encode(defaults.baseParams(admin, asset_, expiration, merkleRoot), lockupLinear, defaults.durations());
if (!isTestOptimizedProfile()) {
return bytes.concat(type(SablierV2MerkleLL).creationCode, constructorArgs);
} else {
Expand All @@ -381,7 +381,7 @@ abstract contract Base_Test is
returns (bytes memory)
{
bytes memory constructorArgs = abi.encode(
defaults.baseParams(admin, asset_, merkleRoot, expiration),
defaults.baseParams(admin, asset_, expiration, merkleRoot),
lockupTranched,
defaults.tranchesWithPercentages()
);
Expand Down
4 changes: 2 additions & 2 deletions test/fork/merkle-lockup/MerkleLT.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ abstract contract MerkleLT_Fork_Test is Fork_Test {
}

struct Vars {
uint256 actualStreamId;
LockupTranched.StreamLT actualStream;
uint256 actualStreamId;
LockupTranched.Tranche[] actualTranches;
uint128[] amounts;
uint256 aggregateAmount;
uint128[] amounts;
MerkleLockup.ConstructorParams baseParams;
uint128 clawbackAmount;
address expectedLT;
Expand Down
4 changes: 2 additions & 2 deletions test/integration/merkle-lockup/MerkleLockup.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ abstract contract MerkleLockup_Integration_Test is Integration_Test {

function createMerkleLL(address admin, uint40 expiration) internal returns (ISablierV2MerkleLL) {
return merkleLockupFactory.createMerkleLL({
baseParams: defaults.baseParams(admin, dai, defaults.MERKLE_ROOT(), expiration),
baseParams: defaults.baseParams(admin, dai, expiration, defaults.MERKLE_ROOT()),
lockupLinear: lockupLinear,
streamDurations: defaults.durations(),
aggregateAmount: defaults.AGGREGATE_AMOUNT(),
Expand Down Expand Up @@ -113,7 +113,7 @@ abstract contract MerkleLockup_Integration_Test is Integration_Test {

function createMerkleLT(address admin, uint40 expiration) internal returns (ISablierV2MerkleLT) {
return merkleLockupFactory.createMerkleLT({
baseParams: defaults.baseParams(admin, dai, defaults.MERKLE_ROOT(), expiration),
baseParams: defaults.baseParams(admin, dai, expiration, defaults.MERKLE_ROOT()),
lockupTranched: lockupTranched,
tranchesWithPercentages: defaults.tranchesWithPercentages(),
aggregateAmount: defaults.AGGREGATE_AMOUNT(),
Expand Down
14 changes: 7 additions & 7 deletions test/utils/Defaults.sol
Original file line number Diff line number Diff line change
Expand Up @@ -119,27 +119,27 @@ contract Defaults is Merkle {
}

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

function baseParams(
address admin,
IERC20 asset_,
bytes32 merkleRoot,
uint40 expiration
uint40 expiration,
bytes32 merkleRoot
)
public
pure
returns (MerkleLockup.ConstructorParams memory)
{
return MerkleLockup.ConstructorParams({
initialAdmin: admin,
asset: asset_,
cancelable: CANCELABLE,
expiration: expiration,
initialAdmin: admin,
ipfsCID: IPFS_CID,
name: NAME,
merkleRoot: merkleRoot,
expiration: expiration,
cancelable: CANCELABLE,
name: NAME,
transferable: TRANSFERABLE
});
}
Expand Down

0 comments on commit 079f432

Please sign in to comment.