Skip to content

Commit

Permalink
prb-feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
smol-ninja committed Apr 11, 2024
1 parent 6cee326 commit 0045f4a
Show file tree
Hide file tree
Showing 64 changed files with 544 additions and 512 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@
".gas-snapshot": "julia"
},
"editor.formatOnSave": true,
"search.exclude": {
"**/node_modules": true
},
"solidity.formatter": "forge"
}
Binary file modified bun.lockb
Binary file not shown.
9 changes: 5 additions & 4 deletions foundry.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
[profile.default]
auto_detect_solc = false
block_timestamp = 1_682_899_200 # May 1, 2023 at 00:00 GMT
block_timestamp = 1_714_518_000 # May 1, 2024 at 00:00 GMT
bytecode_hash = "none"
evm_version = "paris"
extra_output = ['storageLayout']
extra_output = ["storageLayout"]
ffi = true
fs_permissions = [
{ access = "read", path = "out-optimized" },
{ access = "read", path = "./out" },
{ access = "read-write", path = "./cache" }
{ access = "read-write", path = "./cache" },
]
gas_reports = [
"SablierV2Batch",
"SablierV2MerkleLockupFactory",
"SablierV2MerkleLockupLL",
"SablierV2MerkleLockupLT",
]
optimizer = true
optimizer_runs = 10_000
Expand Down Expand Up @@ -63,9 +64,9 @@
avalanche = "https://avalanche-mainnet.infura.io/v3/${API_KEY_INFURA}"
base = "https://mainnet.base.org"
bnb = "https://bsc-dataseed.binance.org"
ethereum = "${RPC_URL_MAINNET}"
gnosis = "https://rpc.gnosischain.com"
localhost = "http://localhost:8545"
ethereum = "${RPC_URL_MAINNET}"
mainnet = "${RPC_URL_MAINNET}"
optimism = "https://optimism-mainnet.infura.io/v3/${API_KEY_INFURA}"
polygon = "https://polygon-mainnet.infura.io/v3/${API_KEY_INFURA}"
Expand Down
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
"url": "https://github.com/sablier-labs/v2-periphery/issues"
},
"dependencies": {
"@openzeppelin/contracts": "5.0.0",
"@prb/math": "github:PaulRBerg/prb-math#a111d11",
"@sablier/v2-core": "github:sablier-labs/v2-core#staging"
"@openzeppelin/contracts": "5.0.2",
"@prb/math": "github:PaulRBerg/prb-math#16419e5686504e15f973ebe73c3a75bd618d6ca4",
"@sablier/v2-core": "github:sablier-labs/v2-core#e57553507b3a388c4a7245e04f36bd1dc014cbc0"
},
"devDependencies": {
"@sphinx-labs/plugins": "^0.30.6",
"@sphinx-labs/plugins": "^0.31.2",
"forge-std": "github:foundry-rs/forge-std#v1.8.1",
"prettier": "^2.8.8",
"solady": "0.0.129",
Expand All @@ -30,6 +30,8 @@
],
"homepage": "https://github.com/sablier-labs/v2-periphery#readme",
"keywords": [
"airdrops",
"airstreams",
"asset-distribution",
"asset-streaming",
"blockchain",
Expand All @@ -50,7 +52,7 @@
"web3"
],
"peerDependencies": {
"@sablier/v2-core": "github:sablier-labs/v2-core#staging"
"@sablier/v2-core": "github:sablier-labs/v2-core"
},
"publishConfig": {
"access": "public"
Expand All @@ -64,7 +66,7 @@
"gas:snapshot": "forge snapshot --no-match-test \"test(Fuzz)?_RevertWhen_\\w{1,}?\"",
"gas:snapshot:optimized": "bun run build:optimized && FOUNDRY_PROFILE=test-optimized forge snapshot --no-match-test \"test(Fork)?(Fuzz)?_RevertWhen_\\w{1,}?\"",
"lint": "bun run lint:sol && bun run prettier:check",
"lint:sol": "forge fmt --check && bun solhint \"{script,src,test}/**/*.sol\"",
"lint:sol": "forge fmt --check && bun solhint \"{precompiles,script,src,test}/**/*.sol\"",
"prepack": "bun install && bash ./shell/prepare-artifacts.sh",
"prettier:check": "prettier --check \"**/*.{json,md,yml}\"",
"prettier:write": "prettier --write \"**/*.{json,md,yml}\"",
Expand Down
2 changes: 1 addition & 1 deletion precompiles/Precompiles.sol

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions script/Base.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ contract BaseScript is Script, Sphinx {
/// @dev Included to enable compilation of the script without a $MNEMONIC environment variable.
string internal constant TEST_MNEMONIC = "test test test test test test test test test test test junk";

/// @dev The default project name for the Sphinx plugin.
string internal constant SPHINX_PROJECT_NAME = "test-test";
/// @dev The project name for the Sphinx plugin.
string internal constant TEST_SPHINX_PROJECT_NAME = "test-test";

/// @dev Needed for the deterministic deployments.
bytes32 internal constant ZERO_SALT = bytes32(0);
Expand Down Expand Up @@ -45,7 +45,7 @@ contract BaseScript is Script, Sphinx {
mnemonic = vm.envOr({ name: "MNEMONIC", defaultValue: TEST_MNEMONIC });
(broadcaster,) = deriveRememberKey({ mnemonic: mnemonic, index: 0 });
}
sphinxProjectName = vm.envOr({ name: "SPHINX_PROJECT_NAME", defaultValue: SPHINX_PROJECT_NAME });
sphinxProjectName = vm.envOr({ name: "SPHINX_PROJECT_NAME", defaultValue: TEST_SPHINX_PROJECT_NAME });
}

modifier broadcast() {
Expand All @@ -54,10 +54,11 @@ contract BaseScript is Script, Sphinx {
vm.stopBroadcast();
}

/// @dev Configures the Sphinx plugin to use Sphinx managed deployment for smart contracts.
/// @dev Configures the Sphinx plugin to manage the deployment of the contracts.
/// Refer to https://github.com/sphinx-labs/sphinx/tree/main/docs.
///
/// CLI example:
/// - bun sphinx propose script/DeployBatch.s.sol --networks testnets --sig "runSphinx()"
/// bun sphinx propose script/DeployBatch.s.sol --networks testnets --sig "runSphinx()"
function configureSphinx() public override {
sphinxConfig.mainnets = ["arbitrum", "avalanche", "base", "bnb", "gnosis", "ethereum", "optimism", "polygon"];
sphinxConfig.orgId = vm.envOr({ name: "SPHINX_ORG_ID", defaultValue: TEST_MNEMONIC });
Expand All @@ -74,7 +75,7 @@ contract BaseScript is Script, Sphinx {
/// - The salt format is "ChainID <chainid>, Version <version>".
/// - The version is obtained from `package.json` using the `ffi` cheatcode:
/// https://book.getfoundry.sh/cheatcodes/ffi
/// - Requires `jq` CLI tool installed: https://jqlang.github.io/jq/
/// - Requires the `jq` CLI installed: https://jqlang.github.io/jq/
function constructCreate2Salt() public returns (bytes32) {
string memory chainId = block.chainid.toString();
string[] memory inputs = new string[](4);
Expand Down
8 changes: 4 additions & 4 deletions script/CreateMerkleLockupLL.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ contract CreateMerkleLockupLL is BaseScript {
ISablierV2LockupLinear lockupLinear;
LockupLinear.Durations streamDurations;
uint256 campaignTotalAmount;
uint256 recipientsCount;
uint256 recipientCount;
}

/// @dev Deploy using Forge CLI.
/// @dev Deploy via Forge.
function runBroadcast(
ISablierV2MerkleLockupFactory merkleLockupFactory,
Params calldata params
Expand All @@ -32,7 +32,7 @@ contract CreateMerkleLockupLL is BaseScript {
merkleLockupLL = _run(merkleLockupFactory, params);
}

/// @dev Deploy using Sphinx CLI.
/// @dev Deploy via Sphinx.
function runSphinx(
ISablierV2MerkleLockupFactory merkleLockupFactory,
Params calldata params
Expand All @@ -57,7 +57,7 @@ contract CreateMerkleLockupLL is BaseScript {
params.lockupLinear,
params.streamDurations,
params.campaignTotalAmount,
params.recipientsCount
params.recipientCount
);
}
}
8 changes: 4 additions & 4 deletions script/CreateMerkleLockupLT.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ contract CreateMerkleLockupLT is BaseScript {
ISablierV2LockupTranched lockupTranched;
MerkleLockupLT.TrancheWithPercentage[] tranchesWithPercentages;
uint256 campaignTotalAmount;
uint256 recipientsCount;
uint256 recipientCount;
}

/// @dev Deploy using Forge CLI.
/// @dev Deploy via Forge.
function runBroadcast(
ISablierV2MerkleLockupFactory merkleLockupFactory,
Params calldata params
Expand All @@ -31,7 +31,7 @@ contract CreateMerkleLockupLT is BaseScript {
merkleLockupLT = _run(merkleLockupFactory, params);
}

/// @dev Deploy using Sphinx CLI.
/// @dev Deploy via Sphinx.
function runSphinx(
ISablierV2MerkleLockupFactory merkleLockupFactory,
Params calldata params
Expand All @@ -56,7 +56,7 @@ contract CreateMerkleLockupLT is BaseScript {
params.lockupTranched,
params.tranchesWithPercentages,
params.campaignTotalAmount,
params.recipientsCount
params.recipientCount
);
}
}
4 changes: 2 additions & 2 deletions script/DeployBatch.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import { BaseScript } from "./Base.s.sol";
import { SablierV2Batch } from "../src/SablierV2Batch.sol";

contract DeployBatch is BaseScript {
/// @dev Deploy using Forge CLI.
/// @dev Deploy via Forge.
function runBroadcast() public virtual broadcast returns (SablierV2Batch batch) {
batch = _run();
}

/// @dev Deploy using Sphinx CLI.
/// @dev Deploy via Sphinx.
function runSphinx() public virtual sphinx returns (SablierV2Batch batch) {
batch = _run();
}
Expand Down
4 changes: 2 additions & 2 deletions script/DeployDeterministicBatch.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import { SablierV2Batch } from "../src/SablierV2Batch.sol";
/// @notice Deploys {SablierV2Batch} at a deterministic address across chains.
/// @dev Reverts if the contract has already been deployed.
contract DeployDeterministicBatch is BaseScript {
/// @dev Deploy using Forge CLI.
/// @dev Deploy via Forge.
function runBroadcast() public virtual broadcast returns (SablierV2Batch batch) {
batch = _run();
}

/// @dev Deploy using Sphinx CLI.
/// @dev Deploy via Sphinx.
function runSphinx() public virtual sphinx returns (SablierV2Batch batch) {
batch = _run();
}
Expand Down
4 changes: 2 additions & 2 deletions script/DeployDeterministicPeriphery.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { SablierV2MerkleLockupFactory } from "../src/SablierV2MerkleLockupFactor
///
/// @dev Reverts if any contract has already been deployed.
contract DeployDeterministicPeriphery is BaseScript {
/// @dev Deploy using Forge CLI.
/// @dev Deploy via Forge.
function runBroadcast()
public
virtual
Expand All @@ -23,7 +23,7 @@ contract DeployDeterministicPeriphery is BaseScript {
(batch, merkleLockupFactory) = _run();
}

/// @dev Deploy using Sphinx CLI.
/// @dev Deploy via Sphinx.
function runSphinx()
public
virtual
Expand Down
4 changes: 2 additions & 2 deletions script/DeployMerkleLockupFactory.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import { BaseScript } from "./Base.s.sol";
import { SablierV2MerkleLockupFactory } from "../src/SablierV2MerkleLockupFactory.sol";

contract DeployMerkleLockupFactory is BaseScript {
/// @dev Deploy using Forge CLI.
/// @dev Deploy via Forge.
function runBroadcast() public virtual broadcast returns (SablierV2MerkleLockupFactory merkleLockupFactory) {
merkleLockupFactory = _run();
}

/// @dev Deploy using Sphinx CLI.
/// @dev Deploy via Sphinx.
function runSphinx() public virtual sphinx returns (SablierV2MerkleLockupFactory merkleLockupFactory) {
merkleLockupFactory = _run();
}
Expand Down
4 changes: 2 additions & 2 deletions script/DeployPeriphery.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { SablierV2Batch } from "../src/SablierV2Batch.sol";
/// 1. {SablierV2Batch}
/// 2. {SablierV2MerkleLockupFactory}
contract DeployPeriphery is BaseScript {
/// @dev Deploy using Forge CLI.
/// @dev Deploy via Forge.
function runBroadcast()
public
virtual
Expand All @@ -21,7 +21,7 @@ contract DeployPeriphery is BaseScript {
(batch, merkleLockupFactory) = _run();
}

/// @dev Deploy using Sphinx CLI.
/// @dev Deploy via Sphinx.
function runSphinx()
public
virtual
Expand Down
22 changes: 13 additions & 9 deletions script/DeployProtocol.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ import { SablierV2Batch } from "../src/SablierV2Batch.sol";

/// @notice Deploys the Sablier V2 Protocol.
contract DeployProtocol is BaseScript {
/// @dev Deploy using Forge CLI.
/// @dev Deploy via Forge.
function runBroadcast(
address initialAdmin,
uint256 maxCount
uint256 maxSegmentCount,
uint256 maxTrancheCount
)
public
virtual
Expand All @@ -30,13 +31,14 @@ contract DeployProtocol is BaseScript {
)
{
(lockupDynamic, lockupLinear, lockupTranched, nftDescriptor, batch, merkleLockupFactory) =
_run(initialAdmin, maxCount);
_run(initialAdmin, maxSegmentCount, maxTrancheCount);
}

/// @dev Deploy using Sphinx CLI.
/// @dev Deploy via Sphinx.
function runSphinx(
address initialAdmin,
uint256 maxCount
uint256 maxSegmentCount,
uint256 maxTrancheCount
)
public
virtual
Expand All @@ -51,12 +53,13 @@ contract DeployProtocol is BaseScript {
)
{
(lockupDynamic, lockupLinear, lockupTranched, nftDescriptor, batch, merkleLockupFactory) =
_run(initialAdmin, maxCount);
_run(initialAdmin, maxSegmentCount, maxTrancheCount);
}

function _run(
address initialAdmin,
uint256 maxCount
uint256 maxSegmentCount,
uint256 maxTrancheCount
)
internal
returns (
Expand All @@ -70,10 +73,11 @@ contract DeployProtocol is BaseScript {
{
// Deploy V2 Core.
nftDescriptor = new SablierV2NFTDescriptor();
lockupDynamic = new SablierV2LockupDynamic(initialAdmin, nftDescriptor, maxCount);
lockupDynamic = new SablierV2LockupDynamic(initialAdmin, nftDescriptor, maxSegmentCount);
lockupLinear = new SablierV2LockupLinear(initialAdmin, nftDescriptor);
lockupTranched = new SablierV2LockupTranched(initialAdmin, nftDescriptor, maxCount);
lockupTranched = new SablierV2LockupTranched(initialAdmin, nftDescriptor, maxTrancheCount);

// Deploy V2 Periphery.
batch = new SablierV2Batch();
merkleLockupFactory = new SablierV2MerkleLockupFactory();
}
Expand Down
Loading

0 comments on commit 0045f4a

Please sign in to comment.