Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Reusable contracts designed to support multiple products, automatically integrat

Custom smart contracts tailored for individual products, integrated using the `custom` onchain action or pricing strategy in Slice.

- **[Examples](./src/examples/)**: Reference implementations and templates
- **[Custom](./src/custom/)**: Product-specific implementations

All hooks inherit from base contracts in `src/utils/`.

Expand Down Expand Up @@ -146,7 +146,7 @@ src/
│ ├── actions/ # Onchain actions (gating, rewards, etc.)
│ ├── pricing/ # Pricing strategies (NFT discounts, VRGDA, etc.)
│ └── pricingActions/ # Combined pricing + action hooks
├── examples/ # Product-specific reference implementations
├── custom/ # Product-specific custom hooks
├── interfaces/ # Core hook interfaces
└── utils/ # Base contracts and utilities
```
Expand All @@ -156,4 +156,4 @@ src/
- [Actions Guide](./src/hooks/actions/README.md)
- [Pricing Strategies Guide](./src/hooks/pricing/README.md)
- [Pricing + Actions Guide](./src/hooks/pricingActions/README.md)
- [Example Implementations](./src/examples/README.md)
- [Custom Implementations](./src/custom/README.md)
6 changes: 3 additions & 3 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dynamic_test_linking = true
libs = ["dependencies", "../core/src", "../core/dependencies"]
fs_permissions = [{ access = "read", path = "./src"}, { access= "read", path = "./broadcast/Deploy.s.sol/8453/run-latest.json"}, { access = "read-write", path = "./deployments"}, { access = "read", path = "./out"}]
remappings = [
"slice/=dependencies/slice-0.0.8/",
"slice/=dependencies/slice-0.0.9/",
"@openzeppelin-4.8.0/=dependencies/@openzeppelin-contracts-4.8.0/",
"@openzeppelin-upgradeable-4.8.0/=dependencies/@openzeppelin-contracts-upgradeable-4.8.0/",
"@erc721a/=dependencies/erc721a-4.3.0/contracts/",
Expand Down Expand Up @@ -44,12 +44,12 @@ remappings_generate = false
remappings_regenerate = false

[dependencies]
slice = "0.0.8"
slice = "0.0.9"
forge-std = "1.9.7"
"@openzeppelin-contracts" = "4.8.0"
"@openzeppelin-contracts-upgradeable" = "4.8.0"
erc721a = "4.3.0"

[lint]
ignore = ["test/**/*.sol","script/**/*.sol", "src/interfaces/*.sol", "src/utils/*.sol", "src/hooks/actions/actions.sol", "src/hooks/pricing/pricing.sol", "src/hooks/pricingActions/pricingActions.sol", "src/examples/actions/BaseGirlsScout.sol"]
ignore = ["test/**/*.sol","script/**/*.sol", "src/interfaces/*.sol", "src/utils/*.sol", "src/hooks/actions/actions.sol", "src/hooks/pricing/pricing.sol", "src/hooks/pricingActions/pricingActions.sol"]
exclude_lints=["mixed-case-function", "mixed-case-variable", "pascal-case-struct"]
2 changes: 1 addition & 1 deletion script/Deploy.s.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
pragma solidity ^0.8.30;

import {console} from "forge-std/console.sol";
import {VmSafe} from "forge-std/Vm.sol";
Expand Down
2 changes: 1 addition & 1 deletion script/ScriptUtils.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
pragma solidity ^0.8.30;

import {console} from "forge-std/console.sol";
import {Script} from "forge-std/Script.sol";
Expand Down
2 changes: 1 addition & 1 deletion script/Seed.s.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;
pragma solidity ^0.8.30;

import {Script} from "forge-std/Script.sol";
import {CommonStorage} from "slice/utils/CommonStorage.sol";
Expand Down
2 changes: 1 addition & 1 deletion script/WriteAddresses.s.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
pragma solidity ^0.8.30;

import {SetUpContractsList} from "./ScriptUtils.sol";

Expand Down
104 changes: 67 additions & 37 deletions script/generate-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,31 @@ echo -e "${GREEN}✓ Contract name: ${CONTRACT_NAME}${NC}"

# Check for duplicate hook names
EXISTING_DIRS=""
case $TYPE in
"action")
EXISTING_DIRS="src/hooks/actions/${CONTRACT_NAME}"
;;
"pricing-strategy")
EXISTING_DIRS="src/hooks/pricing/${CONTRACT_NAME}"
;;
"pricing-action")
EXISTING_DIRS="src/hooks/pricingActions/${CONTRACT_NAME}"
;;
esac
if [ "$SCOPE" = "registry" ]; then
case $TYPE in
"action")
EXISTING_DIRS="src/hooks/actions/${CONTRACT_NAME}"
;;
"pricing-strategy")
EXISTING_DIRS="src/hooks/pricing/${CONTRACT_NAME}"
;;
"pricing-action")
EXISTING_DIRS="src/hooks/pricingActions/${CONTRACT_NAME}"
;;
esac
else
case $TYPE in
"action")
EXISTING_DIRS="src/custom/actions/${CONTRACT_NAME}"
;;
"pricing-strategy")
EXISTING_DIRS="src/custom/pricing/${CONTRACT_NAME}"
;;
"pricing-action")
EXISTING_DIRS="src/custom/pricingActions/${CONTRACT_NAME}"
;;
esac
fi

if [ -d "$EXISTING_DIRS" ]; then
echo -e "${RED}✗ Error: Hook '${CONTRACT_NAME}' already exists at ${EXISTING_DIRS}${NC}"
Expand All @@ -107,18 +121,33 @@ fi
echo -e "${GREEN}✓ Author: ${AUTHOR}${NC}"
echo

# Set directory based on type
case $TYPE in
"action")
DIR="src/hooks/actions/${CONTRACT_NAME}"
;;
"pricing-strategy")
DIR="src/hooks/pricing/${CONTRACT_NAME}"
;;
"pricing-action")
DIR="src/hooks/pricingActions/${CONTRACT_NAME}"
;;
esac
# Set directory based on scope and type
if [ "$SCOPE" = "registry" ]; then
case $TYPE in
"action")
DIR="src/hooks/actions/${CONTRACT_NAME}"
;;
"pricing-strategy")
DIR="src/hooks/pricing/${CONTRACT_NAME}"
;;
"pricing-action")
DIR="src/hooks/pricingActions/${CONTRACT_NAME}"
;;
esac
else
# Product-specific hooks go in custom directory
case $TYPE in
"action")
DIR="src/custom/actions/${CONTRACT_NAME}"
;;
"pricing-strategy")
DIR="src/custom/pricing/${CONTRACT_NAME}"
;;
"pricing-action")
DIR="src/custom/pricingActions/${CONTRACT_NAME}"
;;
esac
fi

# Create directory
mkdir -p "$DIR"
Expand All @@ -132,7 +161,7 @@ echo -e "${BLUE}Generating contract at: ${FILE_PATH}${NC}"
if [ "$SCOPE" = "registry" ] && [ "$TYPE" = "action" ]; then
cat > "$FILE_PATH" << 'EOF'
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
pragma solidity ^0.8.30;

import {
RegistryProductAction,
Expand Down Expand Up @@ -209,7 +238,7 @@ EOF
elif [ "$SCOPE" = "product" ] && [ "$TYPE" = "action" ]; then
cat > "$FILE_PATH" << 'EOF'
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
pragma solidity ^0.8.30;

import {ProductAction, IProductsModule, IProductAction} from "@/utils/ProductAction.sol";

Expand Down Expand Up @@ -265,7 +294,7 @@ EOF
elif [ "$SCOPE" = "registry" ] && [ "$TYPE" = "pricing-strategy" ]; then
cat > "$FILE_PATH" << 'EOF'
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
pragma solidity ^0.8.30;

import {
RegistryProductPrice,
Expand Down Expand Up @@ -325,7 +354,7 @@ EOF
elif [ "$SCOPE" = "product" ] && [ "$TYPE" = "pricing-strategy" ]; then
cat > "$FILE_PATH" << 'EOF'
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
pragma solidity ^0.8.30;

import {ProductPrice, IProductsModule, IProductPrice} from "@/utils/ProductPrice.sol";

Expand Down Expand Up @@ -366,7 +395,7 @@ EOF
elif [ "$SCOPE" = "registry" ] && [ "$TYPE" = "pricing-action" ]; then
cat > "$FILE_PATH" << 'EOF'
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
pragma solidity ^0.8.30;

import {
RegistryProductPriceAction,
Expand Down Expand Up @@ -459,7 +488,7 @@ EOF
elif [ "$SCOPE" = "product" ] && [ "$TYPE" = "pricing-action" ]; then
cat > "$FILE_PATH" << 'EOF'
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
pragma solidity ^0.8.30;

import {
ProductPriceAction,
Expand Down Expand Up @@ -633,7 +662,7 @@ if [ "$SCOPE" = "registry" ]; then
if [ "$TYPE" = "action" ]; then
cat > "$TEST_FILE" << 'EOF'
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
pragma solidity ^0.8.30;

import {RegistryProductAction, RegistryProductActionTest} from "@test/utils/RegistryProductActionTest.sol";
import {CONTRACT_NAME} from "@/hooks/actions/CONTRACT_NAME/CONTRACT_NAME.sol";
Expand Down Expand Up @@ -708,7 +737,7 @@ EOF
elif [ "$TYPE" = "pricing-strategy" ]; then
cat > "$TEST_FILE" << 'EOF'
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
pragma solidity ^0.8.30;

import {RegistryProductPrice, RegistryProductPriceTest} from "@test/utils/RegistryProductPriceTest.sol";
import {CONTRACT_NAME} from "@/hooks/pricing/CONTRACT_NAME/CONTRACT_NAME.sol";
Expand Down Expand Up @@ -763,7 +792,7 @@ EOF
elif [ "$TYPE" = "pricing-action" ]; then
cat > "$TEST_FILE" << 'EOF'
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
pragma solidity ^0.8.30;

import {RegistryProductPriceAction, RegistryProductPriceActionTest} from "@test/utils/RegistryProductPriceActionTest.sol";
import {CONTRACT_NAME} from "@/hooks/pricingActions/CONTRACT_NAME/CONTRACT_NAME.sol";
Expand Down Expand Up @@ -866,8 +895,9 @@ fi

echo
echo -e "${YELLOW}Next steps:${NC}"
echo "1. Review and customize the generated contract"
echo "2. Implement your specific contract logic"
echo "3. Update the test file with your test cases"
echo "4. Run tests with 'forge test'"
echo "5. Deploy using the deployment scripts"
echo "1. Customize the generated contract with your custom logic"
echo "2. Update the test file with your test cases"
echo "3. Run tests with 'forge test'"
if [ "$SCOPE" = "registry" ]; then
echo "4. Deploy by running './script/deploy.sh'"
fi
8 changes: 4 additions & 4 deletions soldeer.lock
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ integrity = "9e60fdba82bc374df80db7f2951faff6467b9091873004a3d314cf0c084b3c7d"

[[dependencies]]
name = "slice"
version = "0.0.8"
url = "https://soldeer-revisions.s3.amazonaws.com/slice/0_0_8_28-08-2025_00:55:13_src.zip"
checksum = "0df8789a04d00a6577f9be207aec4ea0057d9e79569dda522facbd7f04dbed2f"
integrity = "308b4ab7daad57e76ee001b55b2ebb19c707427bee3720fbbaad9d3c7b69021e"
version = "0.0.9"
url = "https://soldeer-revisions.s3.amazonaws.com/slice/0_0_9_28-08-2025_10:52:54_src.zip"
checksum = "7fb47bafed059724f2b4a56719eec2e131c231d9f9a8cbcde5d88958b649cd5d"
integrity = "7ef2c94c7be0d971da96d01d514903e007f957721da4bc0bd9fba004cebafd20"
4 changes: 2 additions & 2 deletions src/examples/README.md → src/custom/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Product-Specific Examples
# Product-Specific Custom Hooks

Reference implementations for custom product hooks without registry support.
Custom product hooks tailored for individual products without registry support.

## When to Use

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
pragma solidity ^0.8.30;

import {IProductsModule, ProductAction} from "@/utils/ProductAction.sol";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
pragma solidity ^0.8.30;

import {IProductsModule, ProductAction} from "@/utils/ProductAction.sol";
import {Ownable} from "@openzeppelin-4.8.0/access/Ownable.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/actions/Allowlisted/Allowlisted.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
pragma solidity ^0.8.30;

import {MerkleProof} from "@openzeppelin-4.8.0/utils/cryptography/MerkleProof.sol";
import {
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/actions/ERC20Gated/ERC20Gated.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
pragma solidity ^0.8.30;

import {ERC20Gate} from "./types/ERC20Gate.sol";
import {
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/actions/ERC20Gated/types/ERC20Gate.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
pragma solidity ^0.8.30;

import {IERC20} from "@openzeppelin-4.8.0/interfaces/IERC20.sol";

Expand Down
2 changes: 1 addition & 1 deletion src/hooks/actions/ERC20Mint/ERC20Mint.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
pragma solidity ^0.8.30;

import {
IProductsModule,
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/actions/ERC20Mint/types/ERC20Data.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
pragma solidity ^0.8.30;

import {ERC20Mint_BaseToken} from "../utils/ERC20Mint_BaseToken.sol";

Expand Down
2 changes: 1 addition & 1 deletion src/hooks/actions/ERC20Mint/utils/ERC20Mint_BaseToken.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
pragma solidity ^0.8.30;

import {ERC20} from "@openzeppelin-4.8.0/token/ERC20/ERC20.sol";

Expand Down
2 changes: 1 addition & 1 deletion src/hooks/actions/ERC721Mint/ERC721Mint.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
pragma solidity ^0.8.30;

import {IProductsModule, RegistryProductAction, HookRegistry, IHookRegistry} from "@/utils/RegistryProductAction.sol";
import {MAX_ROYALTY, ERC721Mint_BaseToken} from "./utils/ERC721Mint_BaseToken.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/actions/ERC721Mint/types/ERC721Data.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
pragma solidity ^0.8.30;

import {ERC721Mint_BaseToken} from "../utils/ERC721Mint_BaseToken.sol";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
pragma solidity ^0.8.30;

import {ERC721A} from "@erc721a/ERC721A.sol";
import {IERC2981, IERC165} from "@openzeppelin-4.8.0/interfaces/IERC2981.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/actions/NFTGated/NFTGated.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
pragma solidity ^0.8.30;

import {IERC721} from "@openzeppelin-4.8.0/interfaces/IERC721.sol";
import {IERC1155} from "@openzeppelin-4.8.0/interfaces/IERC1155.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/actions/NFTGated/types/NFTGate.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
pragma solidity ^0.8.30;

enum NftType {
ERC721,
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/actions/actions.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
pragma solidity ^0.8.30;

import {Allowlisted} from "./Allowlisted/Allowlisted.sol";
import {ERC20Gated} from "./ERC20Gated/ERC20Gated.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
pragma solidity ^0.8.30;

import {IERC721} from "@openzeppelin-4.8.0/token/ERC721/IERC721.sol";
import {IERC1155} from "@openzeppelin-4.8.0/token/ERC1155/IERC1155.sol";
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/pricing/TieredDiscount/TieredDiscount.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
pragma solidity ^0.8.30;

import {IProductsModule} from "slice/interfaces/IProductsModule.sol";
import {RegistryProductPrice, IProductPrice} from "@/utils/RegistryProductPrice.sol";
Expand Down
Loading