@frak-labs/core-sdk 0.0.7 → 0.0.9

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.
@@ -1,174 +1,182 @@
1
- import { Hex, Address } from 'viem';
2
- import { P as PreparedInteraction } from '../interaction-CTQ5-kqe.cjs';
3
-
4
- /**
5
- * Press interactions allow you to track user engagement with articles or other press content on your platform.
6
- * After setting up these interactions, you can create acquisition campaign based on the user engagement with your press content.
7
- *
8
- * :::info
9
- * To properly handle press interactions, ensure that the "Press" product type is enabled in your Business dashboard.
10
- * :::
11
- *
12
- * @description Encode press related user interactions
13
- *
14
- * @group Interactions Encoder
15
- *
16
- * @see {@link PreparedInteraction} The prepared interaction object that can be sent
17
- * @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
18
- */
19
- declare const PressInteractionEncoder: {
20
- /**
21
- * Encode an open article interaction
22
- * @param args
23
- * @param args.articleId - The id of the article the user opened (32 bytes), could be a `keccak256` hash of the article slug, or your internal id
24
- */
25
- openArticle({ articleId }: {
26
- articleId: Hex;
27
- }): PreparedInteraction;
28
- /**
29
- * Encode a read article interaction
30
- * @param args
31
- * @param args.articleId - The id of the article the user opened (32 bytes), could be a `keccak256` hash of the article slug, or your internal id
32
- */
33
- readArticle({ articleId }: {
34
- articleId: Hex;
35
- }): PreparedInteraction;
36
- };
37
-
38
- /**
39
- * Referral interactions allow you to track user sharing activities.
40
- * These interactions are essential for platforms looking to grow their user base through user-to-user referrals and reward systems.
41
- *
42
- * :::info
43
- * To properly handle referral interactions, ensure that the "Referral" product type is enabled in your Business dashboard.
44
- * :::
45
- *
46
- * @description Encode referral related user interactions
47
- *
48
- * @group Interactions Encoder
49
- *
50
- * @see {@link PreparedInteraction} The prepared interaction object that can be sent
51
- * @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
52
- */
53
- declare const ReferralInteractionEncoder: {
54
- /**
55
- * Records the event of a user creating a referral link. Note that this interaction doesn't actually create the link itself; it only sends an event to track that a link was created.
56
- */
57
- createLink(): PreparedInteraction;
58
- /**
59
- * Encode a referred interaction
60
- * @param args
61
- * @param args.referrer - The Ethereum address of the user who made the referral
62
- */
63
- referred({ referrer }: {
64
- referrer: Address;
65
- }): PreparedInteraction;
66
- };
67
-
68
- /**
69
- * Purchase interactions allow you to track user purchases on your platform.
70
- * After setting up these interactions, you can create acquisition campaign based on the user purchase (starting a new one, completed, or even purchase dropped).
71
- *
72
- * :::info
73
- * To properly handle purchase interactions, ensure that the "Purchase" product type is enabled in your Business dashboard, and that you have set up everything correctly in the `Purchasetracker` section.
74
- * :::
75
- *
76
- * :::note
77
- * The `purchaseId` is used on both interactions. It can be computed like this:
78
- *
79
- * ```ts
80
- * const purchaseId = keccak256(concatHex([productId, toHex(externalPurchaseId)]));
81
- * ```
82
- *
83
- * With:
84
- * - `productId`: The id of your product, you can find it in the product dashboard.
85
- * - `externalPurchaseId`: The id of the purchase in your system (e.g. the shopify `order_id`).
86
- * :::
87
- *
88
- * @description Encode purchase related user interactions
89
- *
90
- * @group Interactions Encoder
91
- *
92
- * @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
93
- * @see {@link PreparedInteraction} The prepared interaction object that can be sent
94
- * @see {@link !actions.trackPurchaseStatus | `trackPurchaseStatus()`} Action that will automatically send the purchase upon completion
95
- * @see [Purchase Webhooks](/wallet-sdk/references-api/webhook) Webhooks to be implemented on your side to confirm a purchase
96
- * @see [Purchase Proof](/wallet-sdk/references-api/purchaseProof) Get a merklee proof for the purchase
97
- */
98
- declare const PurchaseInteractionEncoder: {
99
- /**
100
- * Encode a start purchase interaction
101
- * @param args
102
- * @param args.purchaseId - The id of the purchase that is being started.
103
- */
104
- startPurchase({ purchaseId }: {
105
- purchaseId: Hex;
106
- }): PreparedInteraction;
107
- /**
108
- * Encode a complete purchase interaction
109
- * @param args
110
- * @param args.purchaseId - The id of the purchase that is being completed.
111
- * @param args.proof - The merkle proof that the user has completed the purchase (see [Purchase Webhooks](/wallet-sdk/references-api/webhook) for more details).
112
- */
113
- completedPurchase({ purchaseId, proof, }: {
114
- purchaseId: Hex;
115
- proof: Hex[];
116
- }): PreparedInteraction;
117
- /**
118
- * Encode an unsafe complete purchase interaction (when we can't provide the proof)
119
- * @param args
120
- * @param args.purchaseId - The id of the purchase that is being completed.
121
- */
122
- unsafeCompletedPurchase({ purchaseId, }: {
123
- purchaseId: Hex;
124
- }): PreparedInteraction;
125
- };
126
-
127
- /**
128
- * Webshop interactions allow you to track user activities on your webshop.
129
- *
130
- * :::info
131
- * To properly handle webshop interactions, ensure that the "WebShop" product type is enabled in your Business dashboard.
132
- * :::
133
- *
134
- * @description Encode webshop related user interactions
135
- *
136
- * @group Interactions Encoder
137
- *
138
- * @see {@link PreparedInteraction} The prepared interaction object that can be sent
139
- * @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
140
- */
141
- declare const WebShopInteractionEncoder: {
142
- /**
143
- * Encode an open webshop interaction
144
- */
145
- open(): PreparedInteraction;
146
- };
147
-
148
- /**
149
- * Retail interactions allow you to track user activities on your retails products.
150
- *
151
- * :::info
152
- * To properly handle retail interactions, ensure that the "Retail" product type is enabled in your Business dashboard.
153
- * :::
154
- *
155
- * @description Encode retail related user interactions
156
- *
157
- * @group Interactions Encoder
158
- *
159
- * @see {@link PreparedInteraction} The prepared interaction object that can be sent
160
- * @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
161
- */
162
- declare const RetailInteractionEncoder: {
163
- /**
164
- * Encode a customer meeting retail interaction
165
- * @param args
166
- * @param args.agencyId - The id of the agency that the customer is meeting with
167
- *
168
- */
169
- customerMeeting({ agencyId }: {
170
- agencyId: Hex;
171
- }): PreparedInteraction;
172
- };
173
-
174
- export { PressInteractionEncoder, PurchaseInteractionEncoder, ReferralInteractionEncoder, RetailInteractionEncoder, WebShopInteractionEncoder };
1
+ import { Address } from 'viem';
2
+ import { Hex } from 'viem';
3
+
4
+ /**
5
+ * Represent a prepared user interaction, ready to be sent on-chain via the wallet
6
+ */
7
+ declare type PreparedInteraction = {
8
+ handlerTypeDenominator: Hex;
9
+ interactionData: Hex;
10
+ };
11
+
12
+ /**
13
+ * Press interactions allow you to track user engagement with articles or other press content on your platform.
14
+ * After setting up these interactions, you can create acquisition campaign based on the user engagement with your press content.
15
+ *
16
+ * :::info
17
+ * To properly handle press interactions, ensure that the "Press" product type is enabled in your Business dashboard.
18
+ * :::
19
+ *
20
+ * @description Encode press related user interactions
21
+ *
22
+ * @group Interactions Encoder
23
+ *
24
+ * @see {@link PreparedInteraction} The prepared interaction object that can be sent
25
+ * @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
26
+ */
27
+ export declare const PressInteractionEncoder: {
28
+ /**
29
+ * Encode an open article interaction
30
+ * @param args
31
+ * @param args.articleId - The id of the article the user opened (32 bytes), could be a `keccak256` hash of the article slug, or your internal id
32
+ */
33
+ openArticle({ articleId }: {
34
+ articleId: Hex;
35
+ }): PreparedInteraction;
36
+ /**
37
+ * Encode a read article interaction
38
+ * @param args
39
+ * @param args.articleId - The id of the article the user opened (32 bytes), could be a `keccak256` hash of the article slug, or your internal id
40
+ */
41
+ readArticle({ articleId }: {
42
+ articleId: Hex;
43
+ }): PreparedInteraction;
44
+ };
45
+
46
+ /**
47
+ * Purchase interactions allow you to track user purchases on your platform.
48
+ * After setting up these interactions, you can create acquisition campaign based on the user purchase (starting a new one, completed, or even purchase dropped).
49
+ *
50
+ * :::info
51
+ * To properly handle purchase interactions, ensure that the "Purchase" product type is enabled in your Business dashboard, and that you have set up everything correctly in the `Purchasetracker` section.
52
+ * :::
53
+ *
54
+ * :::note
55
+ * The `purchaseId` is used on both interactions. It can be computed like this:
56
+ *
57
+ * ```ts
58
+ * const purchaseId = keccak256(concatHex([productId, toHex(externalPurchaseId)]));
59
+ * ```
60
+ *
61
+ * With:
62
+ * - `productId`: The id of your product, you can find it in the product dashboard.
63
+ * - `externalPurchaseId`: The id of the purchase in your system (e.g. the shopify `order_id`).
64
+ * :::
65
+ *
66
+ * @description Encode purchase related user interactions
67
+ *
68
+ * @group Interactions Encoder
69
+ *
70
+ * @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
71
+ * @see {@link PreparedInteraction} The prepared interaction object that can be sent
72
+ * @see {@link !actions.trackPurchaseStatus | `trackPurchaseStatus()`} Action that will automatically send the purchase upon completion
73
+ * @see [Purchase Webhooks](/wallet-sdk/references-api/webhook) Webhooks to be implemented on your side to confirm a purchase
74
+ * @see [Purchase Proof](/wallet-sdk/references-api/purchaseProof) Get a merklee proof for the purchase
75
+ */
76
+ export declare const PurchaseInteractionEncoder: {
77
+ /**
78
+ * Encode a start purchase interaction
79
+ * @param args
80
+ * @param args.purchaseId - The id of the purchase that is being started.
81
+ */
82
+ startPurchase({ purchaseId }: {
83
+ purchaseId: Hex;
84
+ }): PreparedInteraction;
85
+ /**
86
+ * Encode a complete purchase interaction
87
+ * @param args
88
+ * @param args.purchaseId - The id of the purchase that is being completed.
89
+ * @param args.proof - The merkle proof that the user has completed the purchase (see [Purchase Webhooks](/wallet-sdk/references-api/webhook) for more details).
90
+ */
91
+ completedPurchase({ purchaseId, proof, }: {
92
+ purchaseId: Hex;
93
+ proof: Hex[];
94
+ }): PreparedInteraction;
95
+ /**
96
+ * Encode an unsafe complete purchase interaction (when we can't provide the proof)
97
+ * @param args
98
+ * @param args.purchaseId - The id of the purchase that is being completed.
99
+ */
100
+ unsafeCompletedPurchase({ purchaseId, }: {
101
+ purchaseId: Hex;
102
+ }): PreparedInteraction;
103
+ };
104
+
105
+ /**
106
+ * Referral interactions allow you to track user sharing activities.
107
+ * These interactions are essential for platforms looking to grow their user base through user-to-user referrals and reward systems.
108
+ *
109
+ * :::info
110
+ * To properly handle referral interactions, ensure that the "Referral" product type is enabled in your Business dashboard.
111
+ * :::
112
+ *
113
+ * @description Encode referral related user interactions
114
+ *
115
+ * @group Interactions Encoder
116
+ *
117
+ * @see {@link PreparedInteraction} The prepared interaction object that can be sent
118
+ * @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
119
+ */
120
+ export declare const ReferralInteractionEncoder: {
121
+ /**
122
+ * Records the event of a user creating a referral link. Note that this interaction doesn't actually create the link itself; it only sends an event to track that a link was created.
123
+ */
124
+ createLink(): PreparedInteraction;
125
+ /**
126
+ * Encode a referred interaction
127
+ * @param args
128
+ * @param args.referrer - The Ethereum address of the user who made the referral
129
+ */
130
+ referred({ referrer }: {
131
+ referrer: Address;
132
+ }): PreparedInteraction;
133
+ };
134
+
135
+ /**
136
+ * Retail interactions allow you to track user activities on your retails products.
137
+ *
138
+ * :::info
139
+ * To properly handle retail interactions, ensure that the "Retail" product type is enabled in your Business dashboard.
140
+ * :::
141
+ *
142
+ * @description Encode retail related user interactions
143
+ *
144
+ * @group Interactions Encoder
145
+ *
146
+ * @see {@link PreparedInteraction} The prepared interaction object that can be sent
147
+ * @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
148
+ */
149
+ export declare const RetailInteractionEncoder: {
150
+ /**
151
+ * Encode a customer meeting retail interaction
152
+ * @param args
153
+ * @param args.agencyId - The id of the agency that the customer is meeting with
154
+ *
155
+ */
156
+ customerMeeting({ agencyId }: {
157
+ agencyId: Hex;
158
+ }): PreparedInteraction;
159
+ };
160
+
161
+ /**
162
+ * Webshop interactions allow you to track user activities on your webshop.
163
+ *
164
+ * :::info
165
+ * To properly handle webshop interactions, ensure that the "WebShop" product type is enabled in your Business dashboard.
166
+ * :::
167
+ *
168
+ * @description Encode webshop related user interactions
169
+ *
170
+ * @group Interactions Encoder
171
+ *
172
+ * @see {@link PreparedInteraction} The prepared interaction object that can be sent
173
+ * @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
174
+ */
175
+ export declare const WebShopInteractionEncoder: {
176
+ /**
177
+ * Encode an open webshop interaction
178
+ */
179
+ open(): PreparedInteraction;
180
+ };
181
+
182
+ export { }
@@ -0,0 +1 @@
1
+ import*as e from"viem";let r="0xc0a24ffb",t="0xd5bd0fbe",n="0xb311798f",a="0x010cc3b9",o="0xb2c0f17c",c="0xd87e90c3",i="0x8403aeb4",p="0x4d5b14e0",d="0x74489004",s={dapp:1,press:2,webshop:3,retail:4,referral:30,purchase:31};Object.entries(s).reduce((e,[r,t])=>(e[r]=BigInt(1)<<BigInt(t),e),{});let l={openArticle({articleId:t}){let n=(0,e.concatHex)([r,(0,e.pad)(t,{size:32})]);return{handlerTypeDenominator:(0,e.toHex)(s.press),interactionData:n}},readArticle({articleId:r}){let n=(0,e.concatHex)([t,(0,e.pad)(r,{size:32})]);return{handlerTypeDenominator:(0,e.toHex)(s.press),interactionData:n}}},x={createLink:()=>({handlerTypeDenominator:(0,e.toHex)(s.referral),interactionData:o}),referred({referrer:r}){let t=(0,e.concatHex)([a,(0,e.pad)(r,{size:32})]);return{handlerTypeDenominator:(0,e.toHex)(s.referral),interactionData:t}}},h={startPurchase({purchaseId:r}){let t=(0,e.concatHex)([c,(0,e.pad)(r,{size:32})]);return{handlerTypeDenominator:(0,e.toHex)(s.purchase),interactionData:t}},completedPurchase({purchaseId:r,proof:t}){let n=(0,e.encodeAbiParameters)([{type:"uint256"},{type:"bytes32[]"}],[BigInt(r),t]),a=(0,e.concatHex)([i,n]);return{handlerTypeDenominator:(0,e.toHex)(s.purchase),interactionData:a}},unsafeCompletedPurchase({purchaseId:r}){let t=(0,e.concatHex)([p,(0,e.pad)(r,{size:32})]);return{handlerTypeDenominator:(0,e.toHex)(s.purchase),interactionData:t}}},u={open:()=>({handlerTypeDenominator:(0,e.toHex)(s.webshop),interactionData:n})},m={customerMeeting({agencyId:r}){let t=(0,e.concatHex)([d,(0,e.pad)(r,{size:32})]);return{handlerTypeDenominator:(0,e.toHex)(s.retail),interactionData:t}}};export{l as PressInteractionEncoder,h as PurchaseInteractionEncoder,x as ReferralInteractionEncoder,m as RetailInteractionEncoder,u as WebShopInteractionEncoder};
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "url": "https://twitter.com/QNivelais"
12
12
  }
13
13
  ],
14
- "version": "0.0.7",
14
+ "version": "0.0.9",
15
15
  "description": "Core SDK of the Frak wallet, low level library to interact directly with the frak ecosystem.",
16
16
  "repository": {
17
17
  "url": "https://github.com/frak-id/wallet",
@@ -50,22 +50,22 @@
50
50
  },
51
51
  "./actions": {
52
52
  "import": {
53
- "types": "./dist/actions/index.d.ts",
54
- "default": "./dist/actions/index.js"
53
+ "types": "./dist/actions.d.ts",
54
+ "default": "./dist/actions.js"
55
55
  },
56
56
  "require": {
57
- "types": "./dist/actions/index.d.cts",
58
- "default": "./dist/actions/index.cjs"
57
+ "types": "./dist/actions.d.cts",
58
+ "default": "./dist/actions.cjs"
59
59
  }
60
60
  },
61
61
  "./interactions": {
62
62
  "import": {
63
- "types": "./dist/interactions/index.d.ts",
64
- "default": "./dist/interactions/index.js"
63
+ "types": "./dist/interactions.d.ts",
64
+ "default": "./dist/interactions.js"
65
65
  },
66
66
  "require": {
67
- "types": "./dist/interactions/index.d.cts",
68
- "default": "./dist/interactions/index.cjs"
67
+ "types": "./dist/interactions.d.cts",
68
+ "default": "./dist/interactions.cjs"
69
69
  }
70
70
  }
71
71
  },
@@ -74,8 +74,8 @@
74
74
  "format:check": "biome check .",
75
75
  "format": "biome check --write .",
76
76
  "clean": "rimraf dist",
77
- "build": "tsup && bun run check-exports",
78
- "build:watch": "tsup --watch",
77
+ "build": "rslib build && bun run check-exports",
78
+ "build:watch": "rslib build --watch",
79
79
  "check-exports": "attw --pack --profile node16 .",
80
80
  "typecheck": "tsc --noEmit",
81
81
  "prepublish": "bun run lint && bun run build",
@@ -89,11 +89,11 @@
89
89
  "js-sha256": "^0.11.0"
90
90
  },
91
91
  "devDependencies": {
92
- "@arethetypeswrong/cli": "^0.17.3",
92
+ "@arethetypeswrong/cli": "^0.17.4",
93
+ "@microsoft/api-extractor": "^7.52.1",
94
+ "@rslib/core": "^0.5.4",
93
95
  "@types/node": "^22",
94
- "browserslist": "^4.24.4",
95
- "browserslist-to-esbuild": "^2.1.1",
96
- "tsup": "^8.3.6",
96
+ "ts-checker-rspack-plugin": "^1.1.1",
97
97
  "typescript": "^5"
98
98
  },
99
99
  "browserslist": [