@zoralabs/protocol-deployments 0.3.5-COMMENTS.2 → 0.3.5-COMMENTS.4

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/src/typedData.ts CHANGED
@@ -18,6 +18,7 @@ import {
18
18
  iPremintDefinitionsABI,
19
19
  sponsoredSparksSpenderAddress,
20
20
  commentsAddress,
21
+ callerAndCommenterAddress,
21
22
  } from "./generated/wagmi";
22
23
  import {
23
24
  PremintConfigEncoded,
@@ -31,6 +32,7 @@ import {
31
32
  TokenCreationConfigV3,
32
33
  PermitComment,
33
34
  PermitSparkComment,
35
+ PermitTimedSaleMintAndComment,
34
36
  } from "./types";
35
37
 
36
38
  const premintTypedDataDomain = ({
@@ -446,7 +448,7 @@ const permitSparkCommentTypedDataType = {
446
448
  PermitSparkComment: [
447
449
  { name: "comment", type: "CommentIdentifier" },
448
450
  { name: "sparker", type: "address" },
449
- { name: "sparksQuantity", type: "uint64" },
451
+ { name: "sparksQuantity", type: "uint256" },
450
452
  { name: "deadline", type: "uint256" },
451
453
  { name: "nonce", type: "bytes32" },
452
454
  { name: "referrer", type: "address" },
@@ -546,3 +548,68 @@ export const permitSparkCommentTypedDataDefinition = (
546
548
 
547
549
  // todo: explain
548
550
  export const sparkValue = () => parseEther("0.000001");
551
+
552
+ /**
553
+ * Defines the EIP-712 typed data structure for PermitTimedSaleMintAndComment
554
+ */
555
+ const permitTimedSaleMintAndCommentTypedDataType = {
556
+ PermitTimedSaleMintAndComment: [
557
+ { name: "commenter", type: "address" },
558
+ { name: "quantity", type: "uint256" },
559
+ { name: "collection", type: "address" },
560
+ { name: "tokenId", type: "uint256" },
561
+ { name: "mintReferral", type: "address" },
562
+ { name: "comment", type: "string" },
563
+ { name: "deadline", type: "uint256" },
564
+ { name: "nonce", type: "bytes32" },
565
+ { name: "sourceChainId", type: "uint32" },
566
+ { name: "destinationChainId", type: "uint32" },
567
+ ],
568
+ } as const;
569
+
570
+ /**
571
+ * Generates the domain separator for the CallerAndCommenter contract
572
+ */
573
+ const callerAndCommenterDomain = ({
574
+ signingChainId,
575
+ destinationChainId,
576
+ }: {
577
+ signingChainId: number;
578
+ destinationChainId: keyof typeof callerAndCommenterAddress;
579
+ }) => ({
580
+ name: "CallerAndCommenter",
581
+ version: "1",
582
+ chainId: signingChainId,
583
+ verifyingContract: callerAndCommenterAddress[destinationChainId],
584
+ });
585
+
586
+ /**
587
+ * Generates the typed data definition for a permit timed sale mint and comment operation.
588
+ *
589
+ * This function creates a structured data object that can be used for EIP-712 signing,
590
+ * allowing users to sign a message on one chain that permits a timed sale mint and comment
591
+ * action to be executed on another chain.
592
+ *
593
+ * @param message - The {@link PermitTimedSaleMintAndComment} containing the details of the permit.
594
+ * @param signingAccount - (optional) The account that is signing the message, if different from the commenter.
595
+ * This is typically used when the commenter is a smart wallet, and the signing account is one of its owners.
596
+ * @returns A {@link TypedDataDefinition} object compatible with EIP-712 for structured data hashing and signing,
597
+ * including types, message, primary type, domain, and the signer's account address.
598
+ */
599
+ export const permitTimedSaleMintAndCommentTypedDataDefinition = (
600
+ message: PermitTimedSaleMintAndComment,
601
+ signingAccount?: Address,
602
+ ): TypedDataDefinition<
603
+ typeof permitTimedSaleMintAndCommentTypedDataType,
604
+ "PermitTimedSaleMintAndComment"
605
+ > & { account: Address } => ({
606
+ types: permitTimedSaleMintAndCommentTypedDataType,
607
+ message,
608
+ primaryType: "PermitTimedSaleMintAndComment",
609
+ domain: callerAndCommenterDomain({
610
+ signingChainId: message.sourceChainId,
611
+ destinationChainId:
612
+ message.destinationChainId as keyof typeof callerAndCommenterAddress,
613
+ }),
614
+ account: signingAccount || message.commenter,
615
+ });
package/src/types.ts CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  } from "./generated/wagmi";
8
8
  import { Address } from "viem";
9
9
 
10
- import { commentsABI } from "./generated/wagmi";
10
+ import { commentsABI, callerAndCommenterABI } from "./generated/wagmi";
11
11
 
12
12
  export enum PremintConfigVersion {
13
13
  V1 = "1",
@@ -163,3 +163,10 @@ export type PermitComment = AbiParametersToPrimitiveTypes<
163
163
  export type PermitSparkComment = AbiParametersToPrimitiveTypes<
164
164
  ExtractAbiFunction<typeof commentsABI, "hashPermitSparkComment">["inputs"]
165
165
  >[0];
166
+
167
+ export type PermitTimedSaleMintAndComment = AbiParametersToPrimitiveTypes<
168
+ ExtractAbiFunction<
169
+ typeof callerAndCommenterABI,
170
+ "hashPermitTimedSaleMintAndComment"
171
+ >["inputs"]
172
+ >[0];