@zoralabs/comments-contracts 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +49 -31
- package/README.md +10 -39
- package/abis/AddDelegateCommenterRole.json +9 -0
- package/abis/CallerAndCommenter.json +62 -0
- package/abis/CallerAndCommenterImpl.json +1218 -0
- package/abis/CallerAndCommenterMintAndCommentTest.json +771 -0
- package/abis/CallerAndCommenterSwapAndCommentTest.json +844 -0
- package/abis/CallerAndCommenterTestBase.json +577 -0
- package/abis/CommentsImpl.json +189 -59
- package/abis/CommentsImplConstants.json +106 -0
- package/abis/CommentsPermitTest.json +26 -6
- package/abis/CommentsTest.json +58 -10
- package/abis/Comments_mintAndCommentTest.json +11 -4
- package/abis/Comments_smartWallet.json +711 -0
- package/abis/DeployCallerAndCommenterImpl.json +9 -0
- package/abis/DeployImpl.json +0 -13
- package/abis/DeployNonDeterministic.json +0 -13
- package/abis/DeployScript.json +0 -13
- package/abis/EIP712Upgradeable.json +74 -0
- package/abis/EIP712UpgradeableWithChainId.json +49 -0
- package/abis/ERC20.json +310 -0
- package/abis/GenerateDeterministicParams.json +0 -13
- package/abis/ICallerAndCommenter.json +797 -0
- package/abis/IComments.json +629 -9
- package/abis/IERC20.json +39 -42
- package/abis/IERC20Metadata.json +224 -0
- package/abis/{CommentsDeployerBase.json → IMultiOwnable.json} +8 -2
- package/abis/IProtocolRewards.json +19 -0
- package/abis/ISecondarySwap.json +45 -0
- package/abis/IZoraCreator1155.json +51 -0
- package/abis/IZoraTimedSaleStrategy.json +91 -0
- package/abis/Mock1155.json +75 -1
- package/abis/Mock1155NoCreatorRewardRecipient.json +605 -0
- package/abis/Mock1155NoOwner.json +566 -0
- package/abis/{MockMinter.json → MockDelegateCommenter.json} +12 -2
- package/abis/MockERC20z.json +315 -0
- package/abis/MockMultiOwnable.json +212 -0
- package/abis/MockSecondarySwap.json +95 -0
- package/abis/MockZoraTimedSale.json +139 -0
- package/abis/Ownable2StepUpgradeable.json +138 -0
- package/abis/UnorderedNoncesUpgradeable.json +4 -4
- package/addresses/1.json +9 -0
- package/addresses/10.json +9 -0
- package/addresses/11155111.json +9 -0
- package/addresses/11155420.json +9 -0
- package/addresses/42161.json +9 -0
- package/addresses/7777777.json +9 -0
- package/addresses/81457.json +9 -0
- package/addresses/8453.json +9 -0
- package/addresses/84532.json +9 -0
- package/addresses/999999999.json +7 -2
- package/deterministicConfig/callerAndCommenter.json +8 -0
- package/deterministicConfig/comments.json +2 -2
- package/dist/index.cjs +724 -35
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +723 -35
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/wagmiGenerated.d.ts +1102 -57
- package/dist/wagmiGenerated.d.ts.map +1 -1
- package/package/types.ts +4 -1
- package/package/wagmiGenerated.ts +728 -32
- package/package.json +12 -11
- package/script/AddDelegateCommenterRole.s.sol +24 -0
- package/script/CommentsDeployerBase.sol +102 -19
- package/script/Deploy.s.sol +2 -44
- package/script/DeployCallerAndCommenterImpl.s.sol +29 -0
- package/script/DeployImpl.s.sol +1 -0
- package/script/DeployNonDeterministic.s.sol +22 -13
- package/script/GenerateDeterministicParams.s.sol +32 -4
- package/scripts/generateCommentsTestData.ts +170 -79
- package/src/CommentsImpl.sol +267 -134
- package/src/CommentsImplConstants.sol +44 -0
- package/src/interfaces/ICallerAndCommenter.sol +215 -0
- package/src/interfaces/IComments.sol +189 -42
- package/src/interfaces/IMultiOwnable.sol +10 -0
- package/src/interfaces/ISecondarySwap.sol +40 -0
- package/src/interfaces/IZoraCreator1155.sol +6 -1
- package/src/interfaces/IZoraCreator1155TypesV1.sol +46 -0
- package/src/interfaces/IZoraTimedSaleStrategy.sol +25 -0
- package/src/proxy/CallerAndCommenter.sol +43 -0
- package/src/utils/CallerAndCommenterImpl.sol +376 -0
- package/src/utils/EIP712UpgradeableWithChainId.sol +12 -23
- package/src/version/ContractVersionBase.sol +1 -1
- package/test/CallerAndCommenterTestBase.sol +77 -0
- package/test/CallerAndCommenter_mintAndComment.t copy.sol +214 -0
- package/test/CallerAndCommenter_swapAndComment.t.sol +523 -0
- package/test/Comments.t.sol +166 -29
- package/test/CommentsTestBase.sol +12 -20
- package/test/Comments_delegateComment.t.sol +129 -0
- package/test/Comments_permit.t.sol +131 -44
- package/test/Comments_smartWallet.t.sol +152 -0
- package/test/mocks/Mock1155.sol +12 -1
- package/test/mocks/Mock1155NoCreatorRewardRecipient.sol +65 -0
- package/test/mocks/Mock1155NoOwner.sol +53 -0
- package/test/mocks/MockDelegateCommenter.sol +36 -0
- package/test/mocks/MockIZoraCreator1155.sol +16 -0
- package/test/mocks/MockSecondarySwap.sol +30 -0
- package/test/mocks/MockZoraTimedSale.sol +38 -0
- package/wagmi.config.ts +3 -1
- package/abis/ProxyDeployerScript.json +0 -15
- package/scripts/backfillComments.ts +0 -176
- package/scripts/queries.ts +0 -73
- package/scripts/queryAndSaveComments.ts +0 -48
- package/scripts/queryQuantityOfComments.ts +0 -53
- package/scripts/writeComments.ts +0 -198
- package/src/deployments/CommentsDeployment.sol +0 -14
- package/test/Comments_mintAndComment.t.sol +0 -101
- package/test/mocks/MockMinter.sol +0 -29
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.23;
|
|
3
|
+
|
|
4
|
+
/// @title CommentsImplConstants
|
|
5
|
+
/// @notice Constants for the CommentsImpl contract
|
|
6
|
+
/// @author oveddan / IsabellaSmallcombe
|
|
7
|
+
contract CommentsImplConstants {
|
|
8
|
+
/// @notice this is the zora creator multisig that can upgrade the contract
|
|
9
|
+
bytes32 public constant BACKFILLER_ROLE = keccak256("BACKFILLER_ROLE");
|
|
10
|
+
/// @notice allows to delegate comment
|
|
11
|
+
bytes32 public constant DELEGATE_COMMENTER = keccak256("DELEGATE_COMMENTER");
|
|
12
|
+
/// @notice permission bit for admin
|
|
13
|
+
uint256 public constant PERMISSION_BIT_ADMIN = 2 ** 1;
|
|
14
|
+
/// @notice Zora reward percentage
|
|
15
|
+
uint256 public constant ZORA_REWARD_PCT = 10;
|
|
16
|
+
/// @notice referrer reward percentage
|
|
17
|
+
uint256 public constant REFERRER_REWARD_PCT = 20;
|
|
18
|
+
/// @notice Zora reward percentage when there is no referrer
|
|
19
|
+
uint256 public constant ZORA_REWARD_NO_REFERRER_PCT = 30;
|
|
20
|
+
/// @notice BPS to percent conversion
|
|
21
|
+
uint256 internal constant BPS_TO_PERCENT_2_DECIMAL_PERCISION = 100;
|
|
22
|
+
/// @notice domain name for comments
|
|
23
|
+
string public constant DOMAIN_NAME = "Comments";
|
|
24
|
+
/// @notice domain version for comments
|
|
25
|
+
string public constant DOMAIN_VERSION = "1";
|
|
26
|
+
/// @notice Zora reward reason
|
|
27
|
+
bytes4 constant ZORA_REWARD_REASON = bytes4(keccak256("zoraRewardForCommentDeposited()"));
|
|
28
|
+
/// @notice referrer reward reason
|
|
29
|
+
bytes4 constant REFERRER_REWARD_REASON = bytes4(keccak256("referrerRewardForCommentDeposited()"));
|
|
30
|
+
/// @notice sparks recipient reward reason
|
|
31
|
+
bytes4 constant SPARKS_RECIPIENT_REWARD_REASON = bytes4(keccak256("sparksRecipientRewardForCommentDeposited()"));
|
|
32
|
+
/// @notice permint comment domain
|
|
33
|
+
bytes32 constant PERMIT_COMMENT_DOMAIN =
|
|
34
|
+
keccak256(
|
|
35
|
+
"PermitComment(address contractAddress,uint256 tokenId,address commenter,CommentIdentifier replyTo,string text,uint256 deadline,bytes32 nonce,address commenterSmartWallet,address referrer,uint32 sourceChainId,uint32 destinationChainId)CommentIdentifier(address contractAddress,uint256 tokenId,address commenter,bytes32 nonce)"
|
|
36
|
+
);
|
|
37
|
+
/// @notice comment identifier domain
|
|
38
|
+
bytes32 constant COMMENT_IDENTIFIER_DOMAIN = keccak256("CommentIdentifier(address contractAddress,uint256 tokenId,address commenter,bytes32 nonce)");
|
|
39
|
+
/// @notice permit spark comment domain
|
|
40
|
+
bytes32 constant PERMIT_SPARK_COMMENT_DOMAIN =
|
|
41
|
+
keccak256(
|
|
42
|
+
"PermitSparkComment(CommentIdentifier comment,address sparker,uint256 sparksQuantity,uint256 deadline,bytes32 nonce,address referrer,uint32 sourceChainId,uint32 destinationChainId)CommentIdentifier(address contractAddress,uint256 tokenId,address commenter,bytes32 nonce)"
|
|
43
|
+
);
|
|
44
|
+
}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.20;
|
|
3
|
+
|
|
4
|
+
import {IComments} from "./IComments.sol";
|
|
5
|
+
|
|
6
|
+
interface ICallerAndCommenter {
|
|
7
|
+
/// @notice Occurs when a signature is invalid
|
|
8
|
+
error InvalidSignature();
|
|
9
|
+
|
|
10
|
+
/// @notice Occurs when the deadline has expired
|
|
11
|
+
error ERC2612ExpiredSignature(uint256 deadline);
|
|
12
|
+
/// @notice Occurs when the destination chain ID doesn't match the current chain ID in a permit
|
|
13
|
+
error IncorrectDestinationChain(uint256 wrongDestinationChainId);
|
|
14
|
+
|
|
15
|
+
/// @notice Occurs when attempting to upgrade to a contract with a name that doesn't match the current contract's name
|
|
16
|
+
/// @param currentName The name of the current contract
|
|
17
|
+
/// @param newName The name of the contract being upgraded to
|
|
18
|
+
error UpgradeToMismatchedContractName(string currentName, string newName);
|
|
19
|
+
|
|
20
|
+
/// @notice Occurs when the commenter address doesn't match the expected address
|
|
21
|
+
/// @param expected The address that was expected to be the commenter
|
|
22
|
+
/// @param actual The actual address that attempted to comment
|
|
23
|
+
error CommenterMismatch(address expected, address actual);
|
|
24
|
+
|
|
25
|
+
/// @notice Error thrown when attempting to buy tokens for a collection and tokenId that doesn't have an active sale
|
|
26
|
+
/// @param collection The address of the collection
|
|
27
|
+
/// @param tokenId The ID of the token
|
|
28
|
+
error SaleNotSet(address collection, uint256 tokenId);
|
|
29
|
+
|
|
30
|
+
/// @notice Error thrown when the wrong amount of ETH is sent
|
|
31
|
+
/// @param expected The expected amount of ETH
|
|
32
|
+
/// @param actual The actual amount of ETH sent
|
|
33
|
+
error WrongValueSent(uint256 expected, uint256 actual);
|
|
34
|
+
|
|
35
|
+
/// @notice Struct representing a permit for timed sale minting and commenting
|
|
36
|
+
struct PermitTimedSaleMintAndComment {
|
|
37
|
+
/// @dev The account that is creating the comment and minting tokens.
|
|
38
|
+
/// Must match the account that is signing the permit
|
|
39
|
+
address commenter;
|
|
40
|
+
/// @dev The number of tokens to mint
|
|
41
|
+
uint256 quantity;
|
|
42
|
+
/// @dev The address of the collection contract to mint from
|
|
43
|
+
address collection;
|
|
44
|
+
/// @dev The token ID to mint
|
|
45
|
+
uint256 tokenId;
|
|
46
|
+
/// @dev The address to receive mint referral rewards, if any
|
|
47
|
+
address mintReferral;
|
|
48
|
+
/// @dev The text of the comment
|
|
49
|
+
string comment;
|
|
50
|
+
/// @dev Permit deadline - execution of permit must be before this timestamp
|
|
51
|
+
uint256 deadline;
|
|
52
|
+
/// @dev Nonce to prevent replay attacks
|
|
53
|
+
bytes32 nonce;
|
|
54
|
+
/// @dev Chain ID where the permit was signed
|
|
55
|
+
uint32 sourceChainId;
|
|
56
|
+
/// @dev Chain ID where the permit should be executed
|
|
57
|
+
uint32 destinationChainId;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/// @notice Struct representing a permit for buying on secondary market and commenting
|
|
61
|
+
struct PermitBuyOnSecondaryAndComment {
|
|
62
|
+
/// @dev The account that is creating the comment and buying tokens.
|
|
63
|
+
/// Must match the account that is signing the permit
|
|
64
|
+
address commenter;
|
|
65
|
+
/// @dev The number of tokens to buy
|
|
66
|
+
uint256 quantity;
|
|
67
|
+
/// @dev The address of the collection contract to buy from
|
|
68
|
+
address collection;
|
|
69
|
+
/// @dev The token ID to buy
|
|
70
|
+
uint256 tokenId;
|
|
71
|
+
/// @dev The maximum amount of ETH to spend on the purchase
|
|
72
|
+
uint256 maxEthToSpend;
|
|
73
|
+
/// @dev The sqrt price limit for the swap
|
|
74
|
+
uint160 sqrtPriceLimitX96;
|
|
75
|
+
/// @dev The text of the comment
|
|
76
|
+
string comment;
|
|
77
|
+
/// @dev Permit deadline - execution of permit must be before this timestamp
|
|
78
|
+
uint256 deadline;
|
|
79
|
+
/// @dev Nonce to prevent replay attacks
|
|
80
|
+
bytes32 nonce;
|
|
81
|
+
/// @dev Chain ID where the permit was signed
|
|
82
|
+
uint32 sourceChainId;
|
|
83
|
+
/// @dev Chain ID where the permit should be executed
|
|
84
|
+
uint32 destinationChainId;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
enum SwapDirection {
|
|
88
|
+
BUY,
|
|
89
|
+
SELL
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/// @notice Emitted when tokens are bought or sold on the secondary market and a comment is added
|
|
93
|
+
/// @param commentId The unique identifier of the comment
|
|
94
|
+
/// @param commentIdentifier The struct containing details about the comment
|
|
95
|
+
/// @param quantity The number of tokens bought
|
|
96
|
+
/// @param comment The content of the comment
|
|
97
|
+
/// @param swapDirection The direction of the swap
|
|
98
|
+
event SwappedOnSecondaryAndCommented(
|
|
99
|
+
bytes32 indexed commentId,
|
|
100
|
+
IComments.CommentIdentifier commentIdentifier,
|
|
101
|
+
uint256 indexed quantity,
|
|
102
|
+
string comment,
|
|
103
|
+
SwapDirection indexed swapDirection
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
/// @notice Emitted when tokens are minted and a comment is added
|
|
107
|
+
/// @param commentId The unique identifier of the comment
|
|
108
|
+
/// @param commentIdentifier The struct containing details about the comment
|
|
109
|
+
/// @param quantity The number of tokens minted
|
|
110
|
+
/// @param text The content of the comment
|
|
111
|
+
event MintedAndCommented(bytes32 indexed commentId, IComments.CommentIdentifier commentIdentifier, uint256 quantity, string text);
|
|
112
|
+
|
|
113
|
+
/// @notice Initializes the upgradeable contract
|
|
114
|
+
/// @param owner of the contract that can perform upgrades
|
|
115
|
+
function initialize(address owner) external;
|
|
116
|
+
|
|
117
|
+
/// @notice Mints tokens and adds a comment, without needing to pay a spark for the comment.
|
|
118
|
+
/// @dev The payable amount should be the total mint fee. No spark value should be sent.
|
|
119
|
+
/// @param commenter The address of the commenter
|
|
120
|
+
/// @param quantity The number of tokens to mint
|
|
121
|
+
/// @param collection The address of the 1155 collection to mint from
|
|
122
|
+
/// @param tokenId The 1155 token Id to mint
|
|
123
|
+
/// @param mintReferral The address to receive mint referral rewards, if any
|
|
124
|
+
/// @param comment The comment to be added. If empty, no comment will be added.
|
|
125
|
+
/// @return The identifier of the newly created comment
|
|
126
|
+
function timedSaleMintAndComment(
|
|
127
|
+
address commenter,
|
|
128
|
+
uint256 quantity,
|
|
129
|
+
address collection,
|
|
130
|
+
uint256 tokenId,
|
|
131
|
+
address mintReferral,
|
|
132
|
+
string calldata comment
|
|
133
|
+
) external payable returns (IComments.CommentIdentifier memory);
|
|
134
|
+
|
|
135
|
+
/// @notice Mints tokens and adds a comment, without needing to pay a spark for the comment. Attributes the
|
|
136
|
+
/// comment to the signer of the message. Meant to be used for cross-chain commenting. where a permit
|
|
137
|
+
/// is signed in a chain and then executed in another chain.
|
|
138
|
+
/// @dev The signer must match the commenter field in the permit.
|
|
139
|
+
/// @param permit The PermitTimedSaleMintAndComment struct containing the permit data
|
|
140
|
+
/// @param signature The signature of the permit
|
|
141
|
+
/// @return The identifier of the newly created comment
|
|
142
|
+
function permitTimedSaleMintAndComment(
|
|
143
|
+
PermitTimedSaleMintAndComment calldata permit,
|
|
144
|
+
bytes calldata signature
|
|
145
|
+
) external payable returns (IComments.CommentIdentifier memory);
|
|
146
|
+
|
|
147
|
+
/// @notice Hashes the permit data for a timed sale mint and comment operation
|
|
148
|
+
/// @param permit The PermitTimedSaleMintAndComment struct containing the permit data
|
|
149
|
+
/// @return bytes32 The hash of the permit data for signing
|
|
150
|
+
function hashPermitTimedSaleMintAndComment(PermitTimedSaleMintAndComment memory permit) external view returns (bytes32);
|
|
151
|
+
|
|
152
|
+
/// @notice Buys Zora 1155 tokens on secondary market and adds a comment, without needing to pay a spark for the comment.
|
|
153
|
+
/// @param commenter The address of the commenter. Must match the msg.sender. Commenter will be the recipient of the bought tokens.
|
|
154
|
+
/// @param quantity The number of tokens to buy
|
|
155
|
+
/// @param collection The address of the 1155 collection
|
|
156
|
+
/// @param tokenId The 1155 token Id to buy
|
|
157
|
+
/// @param excessRefundRecipient The address to receive any excess ETH refund
|
|
158
|
+
/// @param maxEthToSpend The maximum amount of ETH to spend on the purchase
|
|
159
|
+
/// @param sqrtPriceLimitX96 The sqrt price limit for the swap
|
|
160
|
+
/// @param comment The comment to be added
|
|
161
|
+
/// @return The identifier of the newly created comment
|
|
162
|
+
/// @dev This function can only be called by the commenter themselves
|
|
163
|
+
function buyOnSecondaryAndComment(
|
|
164
|
+
address commenter,
|
|
165
|
+
uint256 quantity,
|
|
166
|
+
address collection,
|
|
167
|
+
uint256 tokenId,
|
|
168
|
+
address payable excessRefundRecipient,
|
|
169
|
+
uint256 maxEthToSpend,
|
|
170
|
+
uint160 sqrtPriceLimitX96,
|
|
171
|
+
string calldata comment
|
|
172
|
+
) external payable returns (IComments.CommentIdentifier memory);
|
|
173
|
+
|
|
174
|
+
/// @notice Buys tokens on secondary market and adds a comment using a permit
|
|
175
|
+
/// @dev The signer must match the commenter field in the permit.
|
|
176
|
+
/// @param permit The PermitBuyOnSecondaryAndComment struct containing the permit data
|
|
177
|
+
/// @param signature The signature of the permit
|
|
178
|
+
/// @return The identifier of the newly created comment
|
|
179
|
+
function permitBuyOnSecondaryAndComment(
|
|
180
|
+
PermitBuyOnSecondaryAndComment calldata permit,
|
|
181
|
+
bytes calldata signature
|
|
182
|
+
) external payable returns (IComments.CommentIdentifier memory);
|
|
183
|
+
|
|
184
|
+
/// @notice Hashes the permit data for a buy on secondary and comment operation
|
|
185
|
+
/// @param permit The PermitBuyOnSecondaryAndComment struct containing the permit data
|
|
186
|
+
/// @return bytes32 The hash of the permit data for signing
|
|
187
|
+
function hashPermitBuyOnSecondaryAndComment(PermitBuyOnSecondaryAndComment memory permit) external view returns (bytes32);
|
|
188
|
+
|
|
189
|
+
/// @notice Sells Zora 1155 tokens on secondary market and adds a comment. A spark needs to be paid for the comment, if a comment
|
|
190
|
+
/// is to be added.
|
|
191
|
+
/// @param commenter The address of the commenter. Must match the msg.sender. Commenter will be the seller of the tokens.
|
|
192
|
+
/// @param quantity The number of tokens to sell
|
|
193
|
+
/// @param collection The address of the 1155 collection
|
|
194
|
+
/// @param tokenId The 1155 token Id to sell
|
|
195
|
+
/// @param recipient The address to receive the ETH proceeds
|
|
196
|
+
/// @param minEthToAcquire The minimum amount of ETH to receive from the sale
|
|
197
|
+
/// @param sqrtPriceLimitX96 The sqrt price limit for the swap
|
|
198
|
+
/// @param comment The comment to be added
|
|
199
|
+
/// @return The identifier of the newly created comment
|
|
200
|
+
/// @dev This function can only be called by the commenter themselves
|
|
201
|
+
function sellOnSecondaryAndComment(
|
|
202
|
+
address commenter,
|
|
203
|
+
uint256 quantity,
|
|
204
|
+
address collection,
|
|
205
|
+
uint256 tokenId,
|
|
206
|
+
address payable recipient,
|
|
207
|
+
uint256 minEthToAcquire,
|
|
208
|
+
uint160 sqrtPriceLimitX96,
|
|
209
|
+
string calldata comment
|
|
210
|
+
) external payable returns (IComments.CommentIdentifier memory);
|
|
211
|
+
|
|
212
|
+
/// @notice Returns the address of the comments contract
|
|
213
|
+
/// @return address The address of the comments contract
|
|
214
|
+
function comments() external view returns (IComments);
|
|
215
|
+
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity ^0.8.23;
|
|
3
3
|
|
|
4
|
+
/// @title IComments
|
|
5
|
+
/// @notice Interface for the Comments contract, which allows for comments and sparking (liking with value) on Zora 1155 posts
|
|
6
|
+
/// @author oveddan / IsabellaSmallcombe
|
|
4
7
|
interface IComments {
|
|
8
|
+
/// @notice Struct representing a unique identifier for a comment
|
|
5
9
|
struct CommentIdentifier {
|
|
6
10
|
address commenter;
|
|
7
11
|
address contractAddress;
|
|
@@ -9,41 +13,112 @@ interface IComments {
|
|
|
9
13
|
bytes32 nonce;
|
|
10
14
|
}
|
|
11
15
|
|
|
16
|
+
/// @notice Struct representing a comment
|
|
12
17
|
struct Comment {
|
|
13
18
|
// has this comment been created
|
|
14
19
|
bool exists;
|
|
15
20
|
// total sparks for this comment
|
|
16
|
-
|
|
21
|
+
uint256 totalSparks;
|
|
17
22
|
}
|
|
18
23
|
|
|
19
|
-
|
|
24
|
+
/// @notice Struct representing a permit for creating a comment
|
|
25
|
+
struct PermitComment {
|
|
26
|
+
// The account that is creating the comment.
|
|
27
|
+
// Must match the account that is signing the permit
|
|
28
|
+
address commenter;
|
|
29
|
+
// If the commenter, has a smart wallet, the smart wallet address.
|
|
30
|
+
// If not, zero address. If set, this address can be checked
|
|
31
|
+
// to see if the token is owned by the smart wallet.
|
|
32
|
+
address commenterSmartWallet;
|
|
33
|
+
// The contract address that is being commented on
|
|
34
|
+
address contractAddress;
|
|
35
|
+
// The token ID that is being commented on
|
|
36
|
+
uint256 tokenId;
|
|
37
|
+
// The comment identifier of the comment being replied to
|
|
38
|
+
CommentIdentifier replyTo;
|
|
39
|
+
// The text of the comment
|
|
40
|
+
string text;
|
|
41
|
+
// Referrer address - will get referral reward from the spark
|
|
42
|
+
address referrer;
|
|
43
|
+
// Permit deadline - execution of permit must be before this timestamp
|
|
44
|
+
uint256 deadline;
|
|
45
|
+
// Nonce to prevent replay attacks
|
|
46
|
+
bytes32 nonce;
|
|
47
|
+
// Chain the permit was signed on
|
|
48
|
+
uint32 sourceChainId;
|
|
49
|
+
// Chain to execute the permit on
|
|
50
|
+
uint32 destinationChainId;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/// @notice Struct representing a permit for sparking a comment
|
|
54
|
+
struct PermitSparkComment {
|
|
55
|
+
// Comment that is being sparked
|
|
56
|
+
CommentIdentifier comment;
|
|
57
|
+
// Address of the user that is sparking the comment.
|
|
58
|
+
// Must match the address that is signing the permit
|
|
59
|
+
address sparker;
|
|
60
|
+
// Number of sparks to spark
|
|
61
|
+
uint256 sparksQuantity;
|
|
62
|
+
// Permit deadline - execution of permit must be before this timestamp
|
|
63
|
+
uint256 deadline;
|
|
64
|
+
// Nonce to prevent replay attacks
|
|
65
|
+
bytes32 nonce;
|
|
66
|
+
// Referrer address - will get referral reward from the spark
|
|
67
|
+
address referrer;
|
|
68
|
+
// Chain the permit was signed on
|
|
69
|
+
uint32 sourceChainId;
|
|
70
|
+
// Chain to execute the permit on
|
|
71
|
+
uint32 destinationChainId;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/// @notice Event emitted when a comment is created
|
|
75
|
+
/// @param commentId Unique ID for the comment, generated from a hash of the commentIdentifier
|
|
76
|
+
/// @param commentIdentifier Identifier for the comment, containing details about the comment
|
|
77
|
+
/// @param replyToId Unique ID of the comment being replied to (if any)
|
|
78
|
+
/// @param replyTo Identifier of the comment being replied to (if any)
|
|
79
|
+
/// @param sparksQuantity Number of sparks associated with this comment
|
|
80
|
+
/// @param text The actual text content of the comment
|
|
81
|
+
/// @param timestamp Timestamp when the comment was created
|
|
82
|
+
/// @param referrer Address of the referrer who referred the commenter, if any
|
|
20
83
|
event Commented(
|
|
21
|
-
bytes32 indexed commentId, // Unique
|
|
22
|
-
CommentIdentifier
|
|
23
|
-
bytes32 replyToId, // ID of the comment being replied to (if any)
|
|
24
|
-
CommentIdentifier replyTo, //
|
|
25
|
-
|
|
84
|
+
bytes32 indexed commentId, // Unique ID for the comment, generated from a hash of the commentIdentifier
|
|
85
|
+
CommentIdentifier commentIdentifier, // Identifier for the comment, containing details about the comment
|
|
86
|
+
bytes32 replyToId, // Unique ID of the comment being replied to (if any)
|
|
87
|
+
CommentIdentifier replyTo, // Identifier of the comment being replied to (if any)
|
|
88
|
+
uint256 sparksQuantity, // Number of sparks associated with this comment
|
|
26
89
|
string text, // The actual text content of the comment
|
|
27
90
|
uint256 timestamp, // Timestamp when the comment was created
|
|
28
|
-
address referrer // Address of the referrer who referred the commenter
|
|
91
|
+
address referrer // Address of the referrer who referred the commenter, if any
|
|
29
92
|
);
|
|
30
93
|
|
|
31
|
-
|
|
94
|
+
/// @notice Event emitted when a comment is backfilled
|
|
95
|
+
/// @param commentId Unique identifier for the backfilled comment
|
|
96
|
+
/// @param commentIdentifier Identifier for the comment
|
|
97
|
+
/// @param text The actual text content of the backfilled comment
|
|
98
|
+
/// @param timestamp Timestamp when the original comment was created
|
|
99
|
+
/// @param originalTransactionId Transaction ID of the original comment (before backfilling)
|
|
32
100
|
event BackfilledComment(
|
|
33
101
|
bytes32 indexed commentId, // Unique identifier for the backfilled comment
|
|
34
|
-
CommentIdentifier
|
|
102
|
+
CommentIdentifier commentIdentifier, // Identifier for the comment
|
|
35
103
|
string text, // The actual text content of the backfilled comment
|
|
36
104
|
uint256 timestamp, // Timestamp when the original comment was created
|
|
37
105
|
bytes32 originalTransactionId // Transaction ID of the original comment (before backfilling)
|
|
38
106
|
);
|
|
39
107
|
|
|
40
|
-
|
|
108
|
+
/// @notice Event emitted when a comment is Sparked
|
|
109
|
+
/// @param commentId Unique identifier of the comment being sparked
|
|
110
|
+
/// @param commentIdentifier Struct containing details about the comment and commenter
|
|
111
|
+
/// @param sparksQuantity Number of sparks added to the comment
|
|
112
|
+
/// @param sparker Address of the user who sparked the comment
|
|
113
|
+
/// @param timestamp Timestamp when the spark action occurred
|
|
114
|
+
/// @param referrer Address of the referrer who referred the sparker, if any
|
|
41
115
|
event SparkedComment(
|
|
42
116
|
bytes32 indexed commentId, // Unique identifier of the comment being sparked
|
|
43
117
|
CommentIdentifier commentIdentifier, // Struct containing details about the comment and commenter
|
|
44
|
-
|
|
118
|
+
uint256 sparksQuantity, // Number of sparks added to the comment
|
|
45
119
|
address sparker, // Address of the user who sparked the comment
|
|
46
|
-
uint256 timestamp // Timestamp when the spark action occurred
|
|
120
|
+
uint256 timestamp, // Timestamp when the spark action occurred
|
|
121
|
+
address referrer // Address of the referrer who referred the sparker, if any
|
|
47
122
|
);
|
|
48
123
|
|
|
49
124
|
/// @notice Occurs when attempting to add a comment that already exists
|
|
@@ -93,64 +168,136 @@ interface IComments {
|
|
|
93
168
|
/// @param replyAddress The address in the reply identifier
|
|
94
169
|
/// @param replyTokenId The token ID in the reply identifier
|
|
95
170
|
error CommentAddressOrTokenIdsDoNotMatch(address commentAddress, uint256 commentTokenId, address replyAddress, uint256 replyTokenId);
|
|
171
|
+
|
|
96
172
|
/// @notice Occurs when the signature is invalid
|
|
97
173
|
error InvalidSignature();
|
|
98
174
|
|
|
99
175
|
/// @notice Occurs when the destination chain ID doesn't match the current chain ID in a permit
|
|
100
176
|
error IncorrectDestinationChain(uint256 wrongDestinationChainId);
|
|
101
177
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
178
|
+
/// @notice Occurs when the commenter is not a smart wallet owner
|
|
179
|
+
error NotSmartWalletOwner();
|
|
180
|
+
|
|
181
|
+
/// @notice Occurs when the address is not a smart wallet
|
|
182
|
+
error NotSmartWallet();
|
|
183
|
+
|
|
184
|
+
/// @notice Occurs when the deadline has expired
|
|
105
185
|
error ERC2612ExpiredSignature(uint256 deadline);
|
|
106
186
|
|
|
187
|
+
/// @notice Occurs when the funds recipient does not exist
|
|
188
|
+
error NoFundsRecipient();
|
|
189
|
+
|
|
190
|
+
/// @notice Address cannot be zero
|
|
191
|
+
error AddressZero();
|
|
192
|
+
|
|
193
|
+
/// @notice Creates a new comment
|
|
194
|
+
/// @param commenter The address of the commenter
|
|
195
|
+
/// @param contractAddress The address of the contract
|
|
196
|
+
/// @param tokenId The token ID
|
|
197
|
+
/// @param text The text content of the comment
|
|
198
|
+
/// @param replyTo The identifier of the comment being replied to (if any)
|
|
199
|
+
/// @param commenterSmartWalletOwner If the commenter has a smart wallet, the smart wallet owner address
|
|
200
|
+
/// @param referrer The address of the referrer (if any)
|
|
201
|
+
/// @return commentIdentifier The identifier of the created comment, including the nonce
|
|
107
202
|
function comment(
|
|
108
203
|
address commenter,
|
|
109
204
|
address contractAddress,
|
|
110
205
|
uint256 tokenId,
|
|
111
206
|
string calldata text,
|
|
112
207
|
CommentIdentifier calldata replyTo,
|
|
208
|
+
address commenterSmartWalletOwner,
|
|
113
209
|
address referrer
|
|
114
210
|
) external payable returns (CommentIdentifier memory);
|
|
115
211
|
|
|
212
|
+
/// @notice Allows another contract to delegate comment creation on behalf of a user
|
|
213
|
+
/// @param commenter The address of the commenter
|
|
214
|
+
/// @param contractAddress The address of the contract
|
|
215
|
+
/// @param tokenId The token ID
|
|
216
|
+
/// @param text The text content of the comment
|
|
217
|
+
/// @param replyTo The identifier of the comment being replied to (if any)
|
|
218
|
+
/// @param commenterSmartWalletOwner If the commenter has a smart wallet, the smart wallet owner address
|
|
219
|
+
/// @param referrer The address of the referrer (if any)
|
|
220
|
+
/// @return commentIdentifier The identifier of the created comment, including the nonce
|
|
116
221
|
function delegateComment(
|
|
117
222
|
address commenter,
|
|
118
223
|
address contractAddress,
|
|
119
224
|
uint256 tokenId,
|
|
120
225
|
string calldata text,
|
|
121
|
-
CommentIdentifier calldata replyTo
|
|
122
|
-
|
|
226
|
+
CommentIdentifier calldata replyTo,
|
|
227
|
+
address commenterSmartWalletOwner,
|
|
228
|
+
address referrer
|
|
229
|
+
) external payable returns (CommentIdentifier memory, bytes32 commentId);
|
|
123
230
|
|
|
124
|
-
function
|
|
231
|
+
function initialize(address commentsAdmin, address backfiller, address[] calldata delegateCommenters) external;
|
|
125
232
|
|
|
233
|
+
/// @notice Sparks a comment
|
|
234
|
+
/// @param commentIdentifier The identifier of the comment to spark
|
|
235
|
+
/// @param sparksQuantity The quantity of sparks to send
|
|
236
|
+
/// @param referrer The referrer of the comment
|
|
237
|
+
function sparkComment(CommentIdentifier calldata commentIdentifier, uint256 sparksQuantity, address referrer) external payable;
|
|
238
|
+
|
|
239
|
+
/// @notice Returns the value of a single spark
|
|
240
|
+
/// @return The value of a single spark
|
|
126
241
|
function sparkValue() external view returns (uint256);
|
|
127
242
|
|
|
243
|
+
/// @notice Hashes a comment identifier to generate a unique ID
|
|
244
|
+
/// @param commentIdentifier The comment identifier to hash
|
|
245
|
+
/// @return The hashed comment identifier
|
|
128
246
|
function hashCommentIdentifier(CommentIdentifier calldata commentIdentifier) external view returns (bytes32);
|
|
129
247
|
|
|
248
|
+
/// @notice Returns the next nonce for comment creation
|
|
249
|
+
/// @return The next nonce
|
|
130
250
|
function nextNonce() external view returns (bytes32);
|
|
131
251
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
uint256 tokenId;
|
|
136
|
-
CommentIdentifier replyTo;
|
|
137
|
-
string text;
|
|
138
|
-
uint64 sparksQuantity;
|
|
139
|
-
uint256 deadline;
|
|
140
|
-
bytes32 nonce;
|
|
141
|
-
address referrer;
|
|
142
|
-
uint256 sourceChainId;
|
|
143
|
-
uint256 destinationChainId;
|
|
144
|
-
}
|
|
252
|
+
/// @notice Returns the implementation address of the contract
|
|
253
|
+
/// @return The implementation address
|
|
254
|
+
function implementation() external view returns (address);
|
|
145
255
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
256
|
+
/// @notice Returns the total number of sparks a given comment has received
|
|
257
|
+
/// @param commentIdentifier The identifier of the comment
|
|
258
|
+
/// @return The total number of sparks a comment has received
|
|
259
|
+
function commentSparksQuantity(CommentIdentifier memory commentIdentifier) external view returns (uint256);
|
|
260
|
+
|
|
261
|
+
/// @notice Hashes a comment identifier and checks if a comment exists with that id
|
|
262
|
+
/// @param commentIdentifier The comment identifier to check
|
|
263
|
+
/// @return commentId The hashed comment identifier
|
|
264
|
+
/// @return exists Whether the comment exists
|
|
265
|
+
function hashAndCheckCommentExists(CommentIdentifier memory commentIdentifier) external view returns (bytes32 commentId, bool exists);
|
|
266
|
+
|
|
267
|
+
/// @notice Validates that a comment exists and returns its ID
|
|
268
|
+
/// @param commentIdentifier The comment identifier to validate
|
|
269
|
+
/// @return commentId The hashed comment identifier
|
|
270
|
+
function hashAndValidateCommentExists(CommentIdentifier memory commentIdentifier) external view returns (bytes32 commentId);
|
|
271
|
+
|
|
272
|
+
/// @notice Hashes a permit comment struct for signing
|
|
273
|
+
/// @param permit The permit comment struct
|
|
274
|
+
/// @return The hash to sign
|
|
275
|
+
function hashPermitComment(PermitComment calldata permit) external view returns (bytes32);
|
|
276
|
+
|
|
277
|
+
/// @notice Creates a comment on behalf of another account using a signed message
|
|
278
|
+
/// @param permit The permit that was signed off-chain on the source chain
|
|
279
|
+
/// @param signature The signature of the permit comment
|
|
280
|
+
function permitComment(PermitComment calldata permit, bytes calldata signature) external payable;
|
|
281
|
+
|
|
282
|
+
/// @notice Hashes a permit spark comment struct for signing
|
|
283
|
+
/// @param permit The permit spark comment struct
|
|
284
|
+
/// @return The hash to sign
|
|
285
|
+
function hashPermitSparkComment(PermitSparkComment calldata permit) external view returns (bytes32);
|
|
286
|
+
|
|
287
|
+
/// @notice Sparks a comment on behalf of another account using a signed message
|
|
288
|
+
/// @param permit The permit spark comment struct
|
|
289
|
+
/// @param signature The signature of the permit
|
|
290
|
+
function permitSparkComment(PermitSparkComment calldata permit, bytes calldata signature) external payable;
|
|
291
|
+
|
|
292
|
+
/// @notice Backfills comments created by other contracts
|
|
293
|
+
/// @param commentIdentifiers Array of comment identifiers
|
|
294
|
+
/// @param texts Array of comment texts
|
|
295
|
+
/// @param timestamps Array of comment timestamps
|
|
296
|
+
/// @param originalTransactionHashes Array of original transaction hashes
|
|
297
|
+
function backfillBatchAddComment(
|
|
298
|
+
CommentIdentifier[] calldata commentIdentifiers,
|
|
299
|
+
string[] calldata texts,
|
|
300
|
+
uint256[] calldata timestamps,
|
|
301
|
+
bytes32[] calldata originalTransactionHashes
|
|
302
|
+
) external;
|
|
156
303
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.23;
|
|
3
|
+
|
|
4
|
+
/// Extracted interface from Coinbase Smart Wallet's MultiOwnable contract,
|
|
5
|
+
/// which we use to check if an address is an owner of the smart wallet
|
|
6
|
+
/// in tests without having to include the entire contract in the package
|
|
7
|
+
/// Original function can be seen here: https://github.com/coinbase/talaria/blob/main/contracts/src/MultiOwnable.sol
|
|
8
|
+
interface IMultiOwnable {
|
|
9
|
+
function isOwnerAddress(address account) external view returns (bool);
|
|
10
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.23;
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
░░░░░░░░░░░░░░
|
|
8
|
+
░░▒▒░░░░░░░░░░░░░░░░░░░░
|
|
9
|
+
░░▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░
|
|
10
|
+
░░▒▒▒▒░░░░░░░░░░░░░░ ░░░░░░░░
|
|
11
|
+
░▓▓▒▒▒▒░░░░░░░░░░░░ ░░░░░░░
|
|
12
|
+
░▓▓▓▒▒▒▒░░░░░░░░░░░░ ░░░░░░░░
|
|
13
|
+
░▓▓▓▒▒▒▒░░░░░░░░░░░░░░ ░░░░░░░░░░
|
|
14
|
+
░▓▓▓▒▒▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░
|
|
15
|
+
░▓▓▓▓▓▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░
|
|
16
|
+
░▓▓▓▓▒▒▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░
|
|
17
|
+
░░▓▓▓▓▒▒▒▒▒▒░░░░░░░░░░░░░░░░░░░░
|
|
18
|
+
░░▓▓▓▓▓▓▒▒▒▒▒▒▒▒░░░░░░░░░▒▒▒▒▒░░
|
|
19
|
+
░░▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░
|
|
20
|
+
░░▓▓▓▓▓▓▓▓▓▓▓▓▒▒░░░
|
|
21
|
+
|
|
22
|
+
OURS TRULY,
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
interface ISecondarySwap {
|
|
28
|
+
// function sell1155(address erc20zAddress, uint256 num1155ToSell, address payable recipient, uint256 minEthToAcquire, uint160 sqrtPriceLimitX96) external;
|
|
29
|
+
|
|
30
|
+
function buy1155(
|
|
31
|
+
address erc20zAddress,
|
|
32
|
+
uint256 num1155ToBuy,
|
|
33
|
+
address payable recipient,
|
|
34
|
+
address payable excessRefundRecipient,
|
|
35
|
+
uint256 maxEthToSpend,
|
|
36
|
+
uint160 sqrtPriceLimitX96
|
|
37
|
+
) external payable;
|
|
38
|
+
|
|
39
|
+
error SaleNotSet();
|
|
40
|
+
}
|
|
@@ -2,11 +2,16 @@
|
|
|
2
2
|
pragma solidity ^0.8.23;
|
|
3
3
|
|
|
4
4
|
import {IERC1155} from "@openzeppelin/contracts/interfaces/IERC1155.sol";
|
|
5
|
+
import {IZoraCreator1155TypesV1} from "./IZoraCreator1155TypesV1.sol";
|
|
5
6
|
|
|
6
|
-
interface IZoraCreator1155 is IERC1155 {
|
|
7
|
+
interface IZoraCreator1155 is IERC1155, IZoraCreator1155TypesV1 {
|
|
7
8
|
function isAdminOrRole(address user, uint256 tokenId, uint256 role) external view returns (bool);
|
|
8
9
|
|
|
9
10
|
function getCreatorRewardRecipient(uint256 tokenId) external view returns (address);
|
|
10
11
|
|
|
11
12
|
function supportsInterface(bytes4 interfaceId) external view returns (bool);
|
|
13
|
+
|
|
14
|
+
function config() external view returns (address owner, uint96 __gap1, address payable fundsRecipient, uint96 __gap2, address transferHook, uint96 __gap3);
|
|
15
|
+
|
|
16
|
+
function owner() external view returns (address);
|
|
12
17
|
}
|