Skip to content

Commit 3c263b4

Browse files
committed
rename hooks
1 parent 9184fd8 commit 3c263b4

File tree

56 files changed

+282
-287
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+282
-287
lines changed

.gas-snapshot

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
LinearVRGDACorrectnessTest:testParamsSchema() (gas: 9581)
22
LinearVRGDACorrectnessTest:testSetup_HookInitialized() (gas: 5671)
3-
LinearVRGDACorrectnessTest:testSupportsInterface_RegistryPricingStrategy() (gas: 9685)
3+
LinearVRGDACorrectnessTest:testSupportsInterface_RegistryProductPrice() (gas: 9685)
44
LinearVRGDATest:testAlwaystargetPriceInRightConditions(uint256) (runs: 256, μ: 14604, ~: 14369)
55
LinearVRGDATest:testParamsSchema() (gas: 9564)
66
LinearVRGDATest:testPricingAdjustedByQuantity() (gas: 18788)
@@ -11,7 +11,7 @@ LinearVRGDATest:testProductPriceEth() (gas: 26435)
1111
LinearVRGDATest:testProductPriceMultiple() (gas: 29695)
1212
LinearVRGDATest:testSetMultiplePrices() (gas: 171215)
1313
LinearVRGDATest:testSetup_HookInitialized() (gas: 5715)
14-
LinearVRGDATest:testSupportsInterface_RegistryPricingStrategy() (gas: 9684)
14+
LinearVRGDATest:testSupportsInterface_RegistryProductPrice() (gas: 9684)
1515
LinearVRGDATest:testTargetPrice() (gas: 11418)
1616
LogisticVRGDATest:testAlwaysTargetPriceInRightConditions(uint256) (runs: 256, μ: 16809, ~: 16994)
1717
LogisticVRGDATest:testGetTargetSaleTimeDoesNotRevertEarly() (gas: 6630)
@@ -27,7 +27,7 @@ LogisticVRGDATest:testProductPriceEth() (gas: 28425)
2727
LogisticVRGDATest:testProductPriceMultiple() (gas: 34309)
2828
LogisticVRGDATest:testSetMultiplePrices() (gas: 181254)
2929
LogisticVRGDATest:testSetup_HookInitialized() (gas: 5693)
30-
LogisticVRGDATest:testSupportsInterface_RegistryPricingStrategy() (gas: 9752)
30+
LogisticVRGDATest:testSupportsInterface_RegistryProductPrice() (gas: 9752)
3131
LogisticVRGDATest:testTargetPrice() (gas: 13363)
3232
LogisticVRGDATest:test_RevertOverflow_BeyondLimitTokens(uint256,uint256) (runs: 256, μ: 14963, ~: 14978)
3333
NFTDiscountTest:testDeploy() (gas: 5246)
@@ -44,4 +44,4 @@ NFTDiscountTest:testSetProductPrice__Edit_Add() (gas: 249809)
4444
NFTDiscountTest:testSetProductPrice__Edit_Remove() (gas: 230519)
4545
NFTDiscountTest:testSetProductPrice__MultipleCurrencies() (gas: 198172)
4646
NFTDiscountTest:testSetup_HookInitialized() (gas: 5715)
47-
NFTDiscountTest:testSupportsInterface_RegistryPricingStrategy() (gas: 9705)
47+
NFTDiscountTest:testSupportsInterface_RegistryProductPrice() (gas: 9705)

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ src/
2121

2222
Hooks are built around three main interfaces:
2323

24-
- **[`IOnchainAction`](./src/interfaces/IOnchainAction.sol)**: Execute custom logic during purchases (eligibility checks, rewards, etc.)
25-
- **[`IPricingStrategy`](./src/interfaces/IPricingStrategy.sol)**: Calculate dynamic prices for products
24+
- **[`IProductAction`](./src/interfaces/IProductAction.sol)**: Execute custom logic during purchases (eligibility checks, rewards, etc.)
25+
- **[`IProductPrice`](./src/interfaces/IProductPrice.sol)**: Calculate dynamic prices for products
2626
- **[`IHookRegistry`](./src/interfaces/IHookRegistry.sol)**: Enable reusable hooks across multiple products with frontend integration
2727

2828
Hooks can be:
@@ -42,13 +42,13 @@ Here's how hooks integrate into the product purchase flow:
4242
4343
┌─────────────────────┐
4444
│ Price Fetching │ ← `productPrice` called here
45-
│ (before purchase) │ (IPricingStrategy)
45+
│ (before purchase) │ (IProductPrice)
4646
└─────────────────────┘
4747
4848
4949
┌─────────────────────┐
5050
│ Purchase Execution │ ← `onProductPurchase` called here
51-
│ (during purchase) │ (IOnchainAction)
51+
│ (during purchase) │ (IProductAction)
5252
└─────────────────────┘
5353
5454
@@ -85,15 +85,15 @@ The base contracts in `src/utils` are designed to be inherited, providing essent
8585

8686
### Registry (Reusable):
8787

88-
- **`RegistryOnchainAction`**: Base for reusable onchain actions
89-
- **`RegistryPricingStrategy`**: Base for reusable pricing strategies
90-
- **`RegistryPricingStrategyAction`**: Base for reusable pricing + action hooks
88+
- **`RegistryProductAction`**: Base for reusable onchain actions
89+
- **`RegistryProductPrice`**: Base for reusable pricing strategies
90+
- **`RegistryProductPriceAction`**: Base for reusable pricing + action hooks
9191

9292
### Product-Specific
9393

94-
- **`OnchainAction`**: Base for product-specific onchain actions
95-
- **`PricingStrategy`**: Base for product-specific pricing strategies
96-
- **`PricingStrategyAction`**: Base for product-specific pricing + action hooks
94+
- **`ProductAction`**: Base for product-specific onchain actions
95+
- **`ProductPrice`**: Base for product-specific pricing strategies
96+
- **`ProductPriceAction`**: Base for product-specific pricing + action hooks
9797

9898
## Quick Start
9999

@@ -126,12 +126,12 @@ The script will present you with a list of available contracts to deploy. Select
126126

127127
When writing tests for your hooks, inherit from the appropriate base test contract:
128128

129-
- **`RegistryOnchainActionTest`**: For testing `RegistryOnchainAction` contracts
130-
- **`RegistryPricingStrategyTest`**: For testing `RegistryPricingStrategy` contracts
131-
- **`RegistryPricingStrategyActionTest`**: For testing `RegistryPricingStrategyAction` contracts
132-
- **`OnchainActionTest`**: For testing `OnchainAction` contracts
133-
- **`PricingStrategyTest`**: For testing `PricingStrategy` contracts
134-
- **`PricingStrategyActionTest`**: For testing `PricingStrategyAction` contracts
129+
- **`RegistryProductActionTest`**: For testing `RegistryProductAction` contracts
130+
- **`RegistryProductPriceTest`**: For testing `RegistryProductPrice` contracts
131+
- **`RegistryProductPriceActionTest`**: For testing `RegistryProductPriceAction` contracts
132+
- **`ProductActionTest`**: For testing `ProductAction` contracts
133+
- **`ProductPriceTest`**: For testing `ProductPrice` contracts
134+
- **`ProductPriceActionTest`**: For testing `ProductPriceAction` contracts
135135

136136
Inheriting the appropriate test contract for your hook allows you to focus your tests solely on your custom hook logic.
137137

src/examples/README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ This folder contains product-specific smart contract implementations that demons
44

55
## Key Interfaces
66

7-
**IPricingStrategy**:
7+
**IProductPrice**:
88
```solidity
9-
interface IPricingStrategy {
9+
interface IProductPrice {
1010
function productPrice(
1111
uint256 slicerId,
1212
uint256 productId,
@@ -18,9 +18,9 @@ interface IPricingStrategy {
1818
}
1919
```
2020

21-
**IOnchainAction**:
21+
**IProductAction**:
2222
```solidity
23-
interface IOnchainAction {
23+
interface IProductAction {
2424
function isPurchaseAllowed(
2525
uint256 slicerId,
2626
uint256 productId,
@@ -43,15 +43,15 @@ interface IOnchainAction {
4343

4444
## Base Contracts
4545

46-
- **OnchainAction**: Add arbitrary requirements and/or custom logic after product purchase.
47-
- **PricingStrategy**: Customize product pricing logic.
48-
- **PricingStrategyAction**: Provide functionality of both Onchain Actions and Pricing Strategies
46+
- **ProductAction**: Add arbitrary requirements and/or custom logic after product purchase.
47+
- **ProductPrice**: Customize product pricing logic.
48+
- **ProductPriceAction**: Provide functionality of both Onchain Actions and Pricing Strategies
4949

5050
## Key Differences from Registry Hooks
5151

5252
Unlike the reusable hooks in `/hooks/`, these examples:
5353
- Are tailored for specific products/projects
54-
- Inherit directly from base contracts (`OnchainAction`, `PricingStrategy`)
54+
- Inherit directly from base contracts (`ProductAction`, `ProductPrice`)
5555
- Don't implement `IHookRegistry` (not intended for Slice frontend integration)
5656
- Serve as reference implementations and starting points
5757

@@ -68,13 +68,13 @@ Unlike the reusable hooks in `/hooks/`, these examples:
6868

6969
To create a custom product-specific onchain action:
7070

71-
1. **Inherit from OnchainAction**:
71+
1. **Inherit from ProductAction**:
7272
```solidity
73-
import {OnchainAction, IProductsModule} from "@/utils/OnchainAction.sol";
73+
import {ProductAction, IProductsModule} from "@/utils/ProductAction.sol";
7474
75-
contract MyProductAction is OnchainAction {
75+
contract MyProductAction is ProductAction {
7676
constructor(IProductsModule productsModule, uint256 slicerId)
77-
OnchainAction(productsModule, slicerId) {}
77+
ProductAction(productsModule, slicerId) {}
7878
}
7979
```
8080

@@ -108,13 +108,13 @@ function isPurchaseAllowed(
108108

109109
To create a custom product-specific pricing strategy:
110110

111-
1. **Inherit from PricingStrategy**:
111+
1. **Inherit from ProductPrice**:
112112
```solidity
113-
import {PricingStrategy, IProductsModule} from "@/utils/PricingStrategy.sol";
113+
import {ProductPrice, IProductsModule} from "@/utils/ProductPrice.sol";
114114
115-
contract MyProductAction is PricingStrategy {
115+
contract MyProductAction is ProductPrice {
116116
constructor(IProductsModule productsModule, uint256 slicerId)
117-
PricingStrategy(productsModule, slicerId) {}
117+
ProductPrice(productsModule, slicerId) {}
118118
}
119119
```
120120

src/examples/actions/BaseCafe_2.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.20;
33

4-
import {IProductsModule, OnchainAction} from "@/utils/OnchainAction.sol";
4+
import {IProductsModule, ProductAction} from "@/utils/ProductAction.sol";
55

66
/**
77
* @title BaseCafe
88
* @notice Onchain action that mints an NFT to the buyer on every purchase.
99
* @author Slice <jacopo.eth>
1010
*/
11-
contract BaseCafe is OnchainAction {
11+
contract BaseCafe is ProductAction {
1212
/*//////////////////////////////////////////////////////////////
1313
IMMUTABLE STORAGE
1414
//////////////////////////////////////////////////////////////*/
@@ -21,15 +21,15 @@ contract BaseCafe is OnchainAction {
2121
//////////////////////////////////////////////////////////////*/
2222

2323
constructor(IProductsModule productsModuleAddress, uint256 slicerId)
24-
OnchainAction(productsModuleAddress, slicerId)
24+
ProductAction(productsModuleAddress, slicerId)
2525
{}
2626

2727
/*//////////////////////////////////////////////////////////////
2828
FUNCTIONS
2929
//////////////////////////////////////////////////////////////*/
3030

3131
/**
32-
* @inheritdoc OnchainAction
32+
* @inheritdoc ProductAction
3333
* @notice Mint `quantity` NFTs to `account` on purchase
3434
*/
3535
function _onProductPurchase(uint256, uint256, address buyer, uint256 quantity, bytes memory, bytes memory)

src/examples/actions/BaseGirlsScout.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.20;
33

4-
import {IProductsModule, OnchainAction} from "@/utils/OnchainAction.sol";
4+
import {IProductsModule, ProductAction} from "@/utils/ProductAction.sol";
55
import {Ownable} from "@openzeppelin-4.8.0/access/Ownable.sol";
66
import {IERC1155} from "@openzeppelin-4.8.0/interfaces/IERC1155.sol";
77

@@ -10,7 +10,7 @@ import {IERC1155} from "@openzeppelin-4.8.0/interfaces/IERC1155.sol";
1010
* @notice Onchain action that mints Base Girls Scout NFTs to the buyer on every purchase.
1111
* @author Slice <jacopo.eth>
1212
*/
13-
contract BaseGirlsScout is OnchainAction, Ownable {
13+
contract BaseGirlsScout is ProductAction, Ownable {
1414
/*//////////////////////////////////////////////////////////////
1515
IMMUTABLE STORAGE
1616
//////////////////////////////////////////////////////////////*/
@@ -29,7 +29,7 @@ contract BaseGirlsScout is OnchainAction, Ownable {
2929
//////////////////////////////////////////////////////////////*/
3030

3131
constructor(IProductsModule productsModuleAddress, uint256 slicerId)
32-
OnchainAction(productsModuleAddress, slicerId)
32+
ProductAction(productsModuleAddress, slicerId)
3333
Ownable()
3434
{
3535
allowedSlicerIds[2217] = true;
@@ -41,7 +41,7 @@ contract BaseGirlsScout is OnchainAction, Ownable {
4141
//////////////////////////////////////////////////////////////*/
4242

4343
/**
44-
* @inheritdoc OnchainAction
44+
* @inheritdoc ProductAction
4545
* @notice Mint `quantity` NFTs to `account` on purchase
4646
*/
4747
function _onProductPurchase(uint256, uint256, address buyer, uint256 quantity, bytes memory, bytes memory)

src/hooks/actions/Allowlisted/Allowlisted.sol

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ pragma solidity ^0.8.20;
44
import {MerkleProof} from "@openzeppelin-4.8.0/utils/cryptography/MerkleProof.sol";
55
import {
66
IProductsModule,
7-
RegistryOnchainAction,
7+
RegistryProductAction,
88
HookRegistry,
9-
IOnchainAction,
9+
IProductAction,
1010
IHookRegistry
11-
} from "@/utils/RegistryOnchainAction.sol";
11+
} from "@/utils/RegistryProductAction.sol";
1212

1313
/**
1414
* @title Allowlisted
1515
* @notice Onchain action registry for allowlist requirement.
1616
* @author Slice <jacopo.eth>
1717
*/
18-
contract Allowlisted is RegistryOnchainAction {
18+
contract Allowlisted is RegistryProductAction {
1919
/*//////////////////////////////////////////////////////////////
2020
MUTABLE STORAGE
2121
//////////////////////////////////////////////////////////////*/
@@ -26,14 +26,14 @@ contract Allowlisted is RegistryOnchainAction {
2626
CONSTRUCTOR
2727
//////////////////////////////////////////////////////////////*/
2828

29-
constructor(IProductsModule productsModuleAddress) RegistryOnchainAction(productsModuleAddress) {}
29+
constructor(IProductsModule productsModuleAddress) RegistryProductAction(productsModuleAddress) {}
3030

3131
/*//////////////////////////////////////////////////////////////
3232
CONFIGURATION
3333
//////////////////////////////////////////////////////////////*/
3434

3535
/**
36-
* @inheritdoc IOnchainAction
36+
* @inheritdoc IProductAction
3737
* @dev Checks if the account is in the allowlist.
3838
*/
3939
function isPurchaseAllowed(

src/hooks/actions/ERC20Gated/ERC20Gated.sol

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ pragma solidity ^0.8.20;
44
import {ERC20Gate} from "./types/ERC20Gate.sol";
55
import {
66
IProductsModule,
7-
RegistryOnchainAction,
7+
RegistryProductAction,
88
HookRegistry,
9-
IOnchainAction,
9+
IProductAction,
1010
IHookRegistry
11-
} from "@/utils/RegistryOnchainAction.sol";
11+
} from "@/utils/RegistryProductAction.sol";
1212

1313
/**
1414
* @title ERC20Gated
1515
* @notice Onchain action registry for ERC20 gating.
1616
* @author Slice <jacopo.eth>
1717
*/
18-
contract ERC20Gated is RegistryOnchainAction {
18+
contract ERC20Gated is RegistryProductAction {
1919
/*//////////////////////////////////////////////////////////////
2020
MUTABLE STORAGE
2121
//////////////////////////////////////////////////////////////*/
@@ -26,14 +26,14 @@ contract ERC20Gated is RegistryOnchainAction {
2626
CONSTRUCTOR
2727
//////////////////////////////////////////////////////////////*/
2828

29-
constructor(IProductsModule productsModuleAddress) RegistryOnchainAction(productsModuleAddress) {}
29+
constructor(IProductsModule productsModuleAddress) RegistryProductAction(productsModuleAddress) {}
3030

3131
/*//////////////////////////////////////////////////////////////
3232
CONFIGURATION
3333
//////////////////////////////////////////////////////////////*/
3434

3535
/**
36-
* @inheritdoc IOnchainAction
36+
* @inheritdoc IProductAction
3737
* @dev Checks if `account` owns the required amount of all ERC20 tokens.
3838
*/
3939
function isPurchaseAllowed(

src/hooks/actions/ERC20Mint/ERC20Mint.sol

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ pragma solidity ^0.8.20;
33

44
import {
55
IProductsModule,
6-
RegistryOnchainAction,
6+
RegistryProductAction,
77
HookRegistry,
8-
IOnchainAction,
8+
IProductAction,
99
IHookRegistry
10-
} from "@/utils/RegistryOnchainAction.sol";
10+
} from "@/utils/RegistryProductAction.sol";
1111
import {ERC20Data} from "./types/ERC20Data.sol";
1212
import {ERC20Mint_BaseToken} from "./utils/ERC20Mint_BaseToken.sol";
1313

@@ -17,7 +17,7 @@ import {ERC20Mint_BaseToken} from "./utils/ERC20Mint_BaseToken.sol";
1717
* @dev If `revertOnMaxSupplyReached` is set to true, reverts when max supply is exceeded.
1818
* @author Slice <jacopo.eth>
1919
*/
20-
contract ERC20Mint is RegistryOnchainAction {
20+
contract ERC20Mint is RegistryProductAction {
2121
/*//////////////////////////////////////////////////////////////
2222
ERRORS
2323
//////////////////////////////////////////////////////////////*/
@@ -34,14 +34,14 @@ contract ERC20Mint is RegistryOnchainAction {
3434
CONSTRUCTOR
3535
//////////////////////////////////////////////////////////////*/
3636

37-
constructor(IProductsModule productsModuleAddress) RegistryOnchainAction(productsModuleAddress) {}
37+
constructor(IProductsModule productsModuleAddress) RegistryProductAction(productsModuleAddress) {}
3838

3939
/*//////////////////////////////////////////////////////////////
4040
CONFIGURATION
4141
//////////////////////////////////////////////////////////////*/
4242

4343
/**
44-
* @inheritdoc IOnchainAction
44+
* @inheritdoc IProductAction
4545
* @dev If `revertOnMaxSupplyReached` is set to true, returns false when max supply is exceeded.
4646
*/
4747
function isPurchaseAllowed(
@@ -63,7 +63,7 @@ contract ERC20Mint is RegistryOnchainAction {
6363
}
6464

6565
/**
66-
* @inheritdoc RegistryOnchainAction
66+
* @inheritdoc RegistryProductAction
6767
* @notice Mint tokens to the buyer.
6868
* @dev If `revertOnMaxSupplyReached` is set to true, reverts when max supply is exceeded.
6969
*/

0 commit comments

Comments
 (0)